Program for my project

Dear Sir,
Our requirements are:

  1. The servo can travel (rotate) 180 degrees. If it can travel more than 180 degrees (preferred), the programmer can program its travel distance and allow it travel from 0 to 180 degrees and from 180 to 0 degrees, and go forward and back in the same speed.
  2. The time interval between travels (from 0-180 degrees and from 180-0 degrees) and the travel speed (from 0-50 rpm, eg. 20rpm) are all programmable as in following “3”.
  3. when it travels to 180 degrees, it stops moving for 5-30 seconds (eg. 10 seconds), then travels from 180 degrees to 0 degree and stops for 5-30 seconds again, and repeats these process 6-8 times and then has long break for 1-24 (e.g. 8 hours) hours. After the long break, the whole above procedure will be repeated at for least 7 days.
    Thank you and waiting for you reply.
    Yongxin

Dear Sir,
Our requirements are:

  1. The servo can travel (rotate) 180 degrees. If it can travel more than 180 degrees (preferred), the programmer can program its travel distance and allow it travel from 0 to 180 degrees and from 180 to 0 degrees, and go forward and back in the same speed.
  2. The time interval between travels (from 0-180 degrees and from 180-0 degrees) and the travel speed (from 0-50 rpm, eg. 20rpm) are all programmable as in following “3”.
  3. when it travels to 180 degrees, it stops moving for 5-30 seconds (eg. 10 seconds), then travels from 180 degrees to 0 degree and stops for 5-30 seconds again, and repeats these process 6-8 times and then has long break for 1-24 (e.g. 8 hours) hours. After the long break, the whole above procedure will be repeated for at least 7 days.
    Thank you and waiting for you reply.
    Yongxin

I can help you with this. It’s easy to set the servos to one position then another. It’s also easy to set the delays in between moves. I’m not sure I understand #2. Do you mean it has to move very fast? This is also no problem. I will take a stab at your basic atom program in the morning.

thank you. it does not have to move fast, maximum speed is 60 rpm would great enough.
Talk to you tomorrow and have a good evening.
Yongxin

Maybe something like this… I couldn’t test it from home. :wink:
Plug the servo into I/O pin0 and run the program. Not sure about a 24 hour pause though. Accuracy?

[code]servo0 var word
buttona var bit
Position1 con 2000 'about -45 degrees (adjust to desired angle)
Position2 con 4000 'about +45 degrees
Time1 con 2000 '2 second pause value (adjust)
Time2 con 4000 '4 second pause value

sound 9, [100\880, 100\988, 100\1046, 100\1175]
low 0

buttona = in12 'If the A button is pressed on power up it will center the servo
if buttona = 1 then start

testing:
servo0 = 3000 'will center the servo on I/O pin 0

gosub makepulses
goto testing

start:
'serout S_OUT,i57600,[dec3 servo0\3," "] 'just for testing…

servo0 = Position1
gosub makepulses
pause Time1
servo0 = Position2
gosub makepulses
pause Time2
goto start

makepulses:
pulsout 0, servo0
pause 20
return[/code]

It compiled and sort of worked, but I need to make some changes. This works much better. See if you can follow how the program works.

[code]hsPosition var sword
Position1 con -14000 'about -90 degrees (adjust to desired angle)
Position2 con 14000 'about +90 degrees
Time1 con 2000 '2 second pause value (adjust)
Time2 con 4000 '4 second pause value

sound 9, [100\880, 100\988, 100\1046, 100\1175]
low 0
HSERVOENABLE

start:
hsPosition = Position1
hservo[p0\hsPosition]
pause Time1
hsPosition = Position2
hservo[p0\hsPosition]
pause Time2
goto start[/code]

Thank you so much, Jim.
I am going to test it tomorrow morning----I just backed to office.
By the way, should I just try the 2nd program, or both?
Have a good evening.
Yongxin

Just use the second program. It does what you wanted, except for the 24 hour pause. Not sure yet the best way to do that.

Jim,
in my Bot Board, a jumper (I so call it) occupys one pin (out of 3) of I/O pin0. Should I remove that jumper and plug on my servo?
Thanks and waiting for your reply.
Yongxin

I have not checked to see if you wish for the processor to do anything during that 24 hours or not. If not I would probably try the sleep command else I would use the pause command. The issue is that I don’t believe that either command can take a value large enough for a 1 day delay.

But you could always put the delay into some form of loop, something like:

; simple function to sleep for about a day.
_iSADCount var long
SleepADay:
    for _iSADCount = 0 to 60*24    ; number of minutes in a day.
        sleep 60000                        ; sleep the number of milliseconds per minute...
    next
    return

Note: I typed this in on the fly so there may be some problems. Also none of the timers are 100% accurate and there is some overhead for the loop. So you will probably need to adjust the value (60*24) to get an exact timing. Also since I have never run a BAP this long I don’t know what happens when their internal timer counter overflows…

Kurt

You are seeing the AX0-3 pins, look farther to the right for P0-3. :wink: There you can plug in the servo. Make sure to set the power jumper to VS not 5vdc.

Thank you, Jim.
I found P0-3 and moved my Servo to P0 and changed jumper from 5V to VS. After I connected them, the servo still did not move. I could see that y- and p- like letters ware increasing in the terminal 4 window with the music, but the servo was silent…
The thing is still not correct, or I should do somthing else to get the servo move?
Yongxin

Lets see a picture of the wiring. It can answer a lot of questions quickly. A clear picture of the board showing the jumpers and cables would help.

here are the pictures in the attachment.

one more

Err… It is a servo though. It should be in the VS position. The Atom Pro is not fully seated into the socket. The I/O pins may not be making contact. Try pressing it into the socket. Take care not to bend the pins.

two more questions:

  1. To get my servo move, do I need press any of those buttons (A, B and/or C)? (I did not)
  2. I programmed the servo with HPP-21 programmer bebore I started to use Bot Board II. Do these two programmers interfere each other?
    Thanks.
    Yongxin

I have changed the jumper back to the position as shown in your picture and I checked I pushed all things all way to the ends , but the servo still does not move. How long would it be from the “connect” to servo moving normally?
Thank you again and waiting for more instruction.
Yongxin

Do you have an unmodified servo to try? Maybe it would be good to default the servo and try it again.

Lets lay down some foundation work.

Does the green LED light up?

Do you click “program” on the Studio program, and does it complete?

Does the servo hold position or is it movable by hand?

Answer these and we can move on.

Hi, Jim
Does the green LED light up? Yes
Does the servo hold position or is it movable by hand? Yes.
Do you click “program” on the Studio program, and does it complete? Not before–this must be the reason. I like your basic questions----I am really at that level. After I click program, the thing were different: my servo moved once then stopped and the music stopped, too. in the build window, many things were shown up with a end “finished programing”. Now what would be the next step I should take?
Thank you so much and waiting for your further instruction.
By the way, the jumper setting in above picture from innerbreed is correct, right?
Yongxin