Canada
Asked — Edited
Resolved Resolved by CochranRobotics!

Set(Digital Port,On/Off) Questions

I'm having a problem getting the Set(digital port,on/off) to work. If I run this code, it works....once.


Set(1.D22,on)
Sleep(300)
servo(1.D22,90)
sleep(5000)
servo(1.D22,40)
sleep(5000)
servo(1.D22,90)
sleep(5000)
servo(1.D22,130)
sleep(5000)
servo(1.D22,90)
sleep(2500)

Set(1.D22,off)

When I run it again, the servo does not move. The code runs without any errors. The only way I can get it to work again is by shutting down the program and the EZB's and restarting. I must not be doing something right, the port is turned off by the command (i can hear that in the servo) but the Set On command doesn't turn it back on.


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

#1  

Have you tried setting the sleep to a longer delay after the on? Its just a guess on my part. Maybe something like 2500 to see if that works.

you may try this


Set(1.D22,on)
Digital_Wait(1.D22, ON) 

That should pause until the 1.D22 port is on before continuing.

#2  

At the end of your code, you could also use


Set(1.D22,off)
Digital_Wait(1.D22, OFF) 

to make sure the port is off and recognized as off prior to continuing but, this would just be something good to have, and probably not the cause of the issue.

#3  

Ok, I tried it with,


Set(1.D22,on)
Digital_Wait(1.D22, ON) 

and the code doesn't run after those 2 line, just sits there. So that tells me that the port is not turning on. I also tried it with a longer sleep time - that doesn't work either.

#4  

so I think what you think is happening with the digital port isnt really happening.

The Set(1.D22,on) will send a high signal down the signal wire (3.3 v to 5 v probably). This isn't really turning on or off the port, but is more setting the digital port to high or low.

The servo on the other end would get up to 5 volts on the signal wire with what you are doing. Set(1.D22,off) sets the signal cable to 0 volts. I think what is happening is when it goes to 0 volts, the servo stops responding.

I dont know your setup, so maybe this is what you want. Please verify.

#5  

you may be looking for this command if I am right

Release (1.D22)

#6  

servo(1.D22,90)
sleep(5000)
servo(1.D22,40)
sleep(5000)
servo(1.D22,90)
sleep(5000)
servo(1.D22,130)
sleep(5000)
servo(1.D22,90)
sleep(2500)

Release(1.D22)

#7  

set digital is not a servo command. It is for setting a digital port high or low for things like LEDs or other devices needing constant current. Neither the Set On or Set Off should be used on a port with a servo connected.

Alan

#8  

Yep, about the only way that you would do this with a servo is if there was some sort of a relay in place to trip to allow power, but then the servo would need to have some really interesting wiring or circuit board to make it function.

#9  

I clearly did not understand the Set On and Off command. Thanks Dave and Alan for explaining it and you were right, the Release command was what I needed.