Putting robotics at your service™

Free shipping on orders over $200

Understanding of BASIC Programming

Print view Share :
Previous topicNext topic

Page 1 of 1 [ 3 posts ]

Rookie ( offline )
Posts: 42
Posted: 2010-07-26 18:19 
Hey everybody...Im working on a A4WD1/AL5Arm project and gotten to the point of making it wireless with PS2. Im just waiting on another battery that I ordered. When I am done with this step I know next will be programming it. I do have a basic understanding of C++ that I took in class a couple of years ago but I want to learn about BASIC since it seems it is the most common used here in the forum. I found a post that is very helpful with BASIC and what the person was asking viewtopic.php?f=28&t=6338. In the post it mentions the BasicMicro-Forum where you can learn about BASIC programming from the manual. http://forums.basicmicro.net/syntax-man ... t9180.html. I was wondering if anybody can write a simple program for me of a Rover that I can use as an example while I go over the material. For example: have a Rover go forward so many inches/speed, stop for 5 seconds, then reverse inches/speed. Anything that needs to be added is fine. As time goes on I will be posting questions but I feel that a simple program for an example will be helpful.
Thanks guys.


New ( offline )
Posts: 9
Posted: 2011-02-21 20:18 
It's difficult to provide locomotion code without knowing what motor controller you are using. Most of them have different commands.

I'm building a Lynxmotion Rover, http://www.richardvannoy.info/rover.php and What I'm doing is testing each thing, one at a time.
My plan is to test sound, the Ping Sensor, The Sharp GP2D12 IR sensors, then the motor controller in that order. For example, here is my sound test code which should work on your board with no hardware or modifications.

Code:
; sound.bas 
; A program to test the piezo speaker on the BasicATOM Pro 28
; On this board, Pin 9 is hardwired to the speaker, so this
; requires no wiring or components.

freq var word ; The frequency to send to the speaker. Word is
                     ; used to allow numbers up to 65,535.

for freq = 500 to 10000 step 500
  sound P9, [1000\freq] ;step through the frequencies
  ;   P9 = Pin 9, the output to the speaker
  ; 1000 = duration = 1000 milliseconds or one second
  ; freq = The frequency sent to the speaker
next

; After running the code above, the three frequencies
; 1500, 4000 and 5000 seemed clearest and loudest, so
; these three wil be the foundation for the rover's
; audio inventory. Here is one second of each:
sound P9, [1000\1500]
sound P9, [1000\4000]
sound P9, [1000\5000]

_________________
College Electronics and Computer Programming Instructor
http://www.RichardVannoy.info


User avatar
Guru ( offline )
Posts: 4913
Posted: 2011-02-21 20:52 
Are you using a sabertooth as the motor controller. If so than the tutorials have several programs to do some things with the rover. But these are usually very simple things like drive the rover forward or backward, by supplying a PWM signal, where if the pulse width is near 1500us the motors stop and if it the pulse width is less than this it goes one direction and if it is more it goes the other direction. The farther from 1500 the faster it goes... This works fine for driving the rover around with the PS2 controller...

However it does not provide any real exact control to allow you to say go at some actual speed or for some specific distance. You can experiment some and get some control, but if you want more real control, than you need additional feedback. One way to do this is by the use of encoders, such as (http://www.lynxmotion.com/p-448-quadrat ... cable.aspx). These require motors that have an external shaft like: http://www.lynxmotion.com/p-653-gear-he ... shaft.aspx. Basic Micro sells a set of motor controller like: http://www.lynxmotion.com/p-765-robocla ... oller.aspx that allow you to actually issues commands like go forward at some speed, or for some distance...

I have done some playing around with the roboclaw on a tri-track, which operates more or less the same as a rover. There are more details and code up on the thread: viewtopic.php?f=20&t=6205

Good Luck
Kurt


 

All times are UTC - 5 hours [ DST ]. It is currently 2014-10-24 20:36
Feedback Form
Feedback Form