简体   繁体   中英

Impulse length - Arduino -> Raspberry

I dont know why is this happening but am quite pissed off :-), because am struggling with this for two days now..

HW: Arduino board --> Raspberry Model 2 B

Am sending one second impulse from arduino mega digital pin 8 to raspberry. I added voltage divider so i have clean 3,25V impulse.

RSP reads most of impulses correctly but sometimes i get false readings. Eg one impulse is triggered and few are not or it starts to trigger impulses but I didn't send any from arduino side.

I try with pullup, pulldown setup but the problem is the same. Maybe i should define that the "impulse" is value that last 1 second and everything else is "garbage" ?. If so, how to make this ?

CODE:

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
...
GPIO.Cleanup()

The funny part is that if i test the impulse from RSP 3,3V pin, it works every time ( of course with pull_down setup ). So, what could be a problem ? 3,3V and 3,25 is no difference at all and RSP defines HIGH from 2.8 - 3.3V...

Any ideas ?

For me, it's more a matter of electronic.

In fact, for that kind of library, we can assume that the functions work correctly (I suppose that you wrote correct code that was built like that: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/ ).

I believe that the electronic problem can come from several sources:

  • Either your ground is badly connected (or it's not the same for the arduino and the rasperry pi). So, the reference tension isn't the same and a 0V for the arduino can be 1V for the raspberry pi.
  • It can also be a result of a bad interpretation of when your circuit is on and off. Don't forget that to put a plain 0V in the input of the raspberry pi (when the circuit is off). You need to explicitly write 0V at the output of the arduino (I mean: digitalWrite(ledPin, LOW); ) otherwise your pin would not be "grounded" but "floating" and the tension can fluctuate from any value (close to 0) to another depending on environmental factors. (to achieve it, you can also use pull down resistances, see: http://playground.arduino.cc/CommonTopics/PullUpDownResistor ).

  • It can also be a transient phenomenon due to unwanted capacitive reactions. So, when your current changes quickly, the circuit cannot follow it instantaneously and it will produce some voltage glitches.

I suggest checking the two first points . If it cannot solve your problem, it should be related to the second point and you could handle it with capacitors and wait times.

I hope it will help :)

Thank you for replay. This are the test's that I made today. - I have connected the zener diode to get the 3,3v and this part is good - tested with different impulse lengths None of them worked.

It's interesting, if i start the RSP script and if i just wait for impulse ( without triggering it ) i will get some 30 reading in few minutes. So it looks like that there is something going on.

I disabled this part of the code in arduino, but i still get this readings... Btw. should i connect arduino and rsp GND together ?

E.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM