Award
Congratulations CochranRobotics, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Set(digital Port,on/off) Questions

Assistance Requested

Help bhouston with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

bhouston claims to have checked these sources:
 
#1

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

Code:


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.

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

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

Code:


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


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

#3

At the end of your code, you could also use

Code:


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.

#4

Ok, I tried it with,

Code:


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.

#5

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.

#6

you may be looking for this command if I am right

Release (1.D22)

#7

Code:


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)

#8

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

#9

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.

#10

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.