I was wondering if there is some way to control a servo's position with my computer.
for example when i click a button on my screen the servo goes to a defined position.
A circuit diagram or any code would be helpfull
so what type of code do i write for vb??
could you give me a sample
This is indeed possible but the picaxe terminal will not do it. Instead you would need to write a small piece of code for your computer to keep an eye on the keyboard, and when something is hit, send off a bit of data via your serial cable to the picaxe. This could be written in Processing, java, VB, python, pearl or whatever you would like.
Another option is to simply plug the keyboard into the picaxe. The picaxe supports PS2 keyboards --I think the command is keyin or kbin... something like that.
Is it possible to do something similar but the servo changes position when i press a button on my keyboard??
ok. thanks again
baud rate is how fast you are sending data back and forth. The picaxe chips are famously slow in this regard. I think the older ones top out at 4800 baud or 9600 if you double thier frequency. I would say, use 4800 or 9600 for everything unless otherwise stated somewhere (i.e. a LCD module or something). You should also know that picaxe uses an inverted signal. This will never be a problem with the picaxe terminal going to a picaxe chip but if you use another terminal program or a different sync cable, this may become an issue. When using the "regular" serial command, there is a "N" or "T" before the baud --N2400 or T2400. This is to tell the chip that you want iNverted signals or True signals.
What you just did with the terminal is also the same thing you would do to get 2 picaxes talking to eachother etc. Note: If you have a program in the chip that uses sertxd or serrxd, you will have to use the reset button the next time you want to sync a new program.
Add this to your program (Put it right after each servo command):
sertxd ("I just got your command, you sent ",b1)
sertxd(10,13) 'this is linefeed and carrage return (i.e. goto next line on the terminal)
Oh, just one last question.
what is baud rate?
and what does changing the baud rate number do?
Baud rate is a measure of how fast digital communications happen, in this case between the PICAXE and the computer. The higher the baud, the more bits of information get sent every second.
If the baud rate doesn't match for both devices, the comms won't work. Increasing the baud rate on both devices allows for more data to be sent per second, or the same amount of data to be sent faster, but the signal is more likely to be affected by noise so you get more errors.
AWESOME!! it worked exactly how i wanted it to.
Thankyou so much :D
Cool, you have done some homework and are on the step you should be on --sorry about jumping throught the hoops.
The sertxd and serrxd commands use the picaxe terminal which will pop up with F8 after you have sync'ed your program in. The terminal allows you to send data to your picaxe. You can receive from the picaxe as well.
Your code will be something like:
select case b1
servo(pin_number,wherever you want it)
servo(pin_number,some other position)
Now, you really should use servo at the top and servopos after that and yadda yadda, but the above should work and will change positions when you hit a,b or c on the terminal then hit "send".
Give me a shout with any problems.