sensors in Robyns Torso

Hi!

I am going to use a pir and an ultrasonic sensor in the chest of Robyn

This is what I use in IDE

https://github.com/MyRobotLab/pyrobotlab/blob/master/home/Markus/TorsoSe...

and it prints

169cm
1
152cm
1
157cm
1
178cm
0
185cm
0
 
so the sensors are working
 
I need some help to get this working in MRL
moz4r's picture

Hi Markus !!This s the

Hi Markus !!

This s the function I use with the last MRL/mrlcomm. Thanks our friend calamity for the solution :

right=Runtime.create("i01.right", "Arduino")
right.setBoard("atmega2560")
right = Runtime.start("i01.right", "Arduino")
right.connect("COM4")
 
def publishPin(pins):
    for pin in range(0, len(pins)):
        print pins[pin].address, pins[pin].value
 
right.addListener("publishPinArray","python","publishPin")
right.enablePin(54,1) ->>> THE NUMBER 1 IS HOW MANY POLLS / SECONDS

 

post : http://myrobotlab.org/content/mrl-1742-analog-reader-correct-method

Markus's picture

thanks! It works fine with

thanks!

It works fine with the pir sensor

but not with the ultrasonic sensor

moz4r's picture

Great ! about ultrasonnic

Great ! about ultrasonnic maybe you can increase the number of pollings / seconds and and read the better value

Markus's picture

in IDE script its connected

in IDE script its connected to a digital input

I think the signal is a pulse not a voltage from 0 to 5

That's Why it doesn't work on analog input

I think!!!

Mats's picture

Ultrasonic distance sensor

Hi Markus

I checked the code in MRLComm and the code for the Ultrasonic sensor needs to be reworked. 

https://github.com/MyRobotLab/myrobotlab/blob/develop/src/resource/Ardui...

Is it the HC-SR04 that you are using ( from Kjell ) ?

If it is, then I could get one today on my way home from work. 

/Mats

 

Markus's picture

Hi Mats! Yes it's the one

Hi Mats!
Yes it's the one from Kjell

https://www.kjell.com/se/sortiment/el-verktyg/elektronik/arduino/moduler...

wvantoorn's picture

Hi markus, you need to set

Hi markus, you need to set the trigger and echo pin in the

at least i think this was it.

moz4r's picture

I don't understand something

I don't understand something about sensors and mrl, I want to use the good method when I use them ( i just tested with succes hall effect sensors via enablepin array )

What is the difference between use the analog reader ( enablepin ) and embeded sensor reader ? ( I saw here a file like MrlUltrasonic.h )

Mats's picture

Ultrasonic device

The ultrasonic device does not return an analog value. It works by sending out a high frequency tone, and then listens for the sound to be returned ( bouncing back on an object ). So the reading is the time it takes from the sound to be sent away until it returns. Sound travels 300m/s. So if it takes 10ms for the sound to come back, the distance to the object is 3m.

That logic need to be in MRLComm, since the Ultrasonic sensor doesnt' measure that time. The pin just changes from low to high when the sound comes back.

 

moz4r's picture

Ok !! Thank you for this info

Ok !! Thank you for this info i learn everyday . so if i understand mrlcomm do the calculation and publish a distance ?