Shop OBEX P1 Docs P2 Docs Learn Events
SX/B robotics? — Parallax Forums

SX/B robotics?

HenrymouHenrymou Posts: 128
edited 2007-06-18 17:11 in General Discussion
I have just learned how to use the SX/B compiler in the first experiments of the book, but
Is SX/B useful in robotics?
can an SX chip using an SX/B program

run servos?

use ultrasound sensors?

use IR sensors?

and do other things?

I can't find any program examples, and I can't find out how to run servos in the the book

help!

-Henry

yeah.gif

signature move

Comments

  • JonnyMacJonnyMac Posts: 8,942
    edited 2007-06-13 21:35
    Yes on all counts.

    You can use PULSOUT to run servos (just like in PBASIC), use an ISR to manage them in the background (I've shown how in another thread), or with the SX48 you can use the Timers to generate servo command signals (see the SX/B help file).
  • HenrymouHenrymou Posts: 128
    edited 2007-06-13 22:16
    yeah, but I don't know anything about da SX
    from the bottom up:
    how do I control standard servos?
  • JonnyMacJonnyMac Posts: 8,942
    edited 2007-06-13 22:43
    If you don't know anything about the SX the best to start is the Parallax web site, they have lots of information. What language do you want to use with the SX?
  • HenrymouHenrymou Posts: 128
    edited 2007-06-13 23:09
    SX/B
    ok, I downloaded the book, I still don't understand how to drive servos
  • JonnyMacJonnyMac Posts: 8,942
    edited 2007-06-14 00:39
    Do you know how servos work at all? That's step 1. If you understand that a servo wants a 1.0 to 2.0 millisecond pulse every 20 milliseconds you can use PULSOUT and PAUSE to achieve these ends. You need to set the control pin to be an output low first, because PULSOUT simply inverts the pin state for the specified period.
  • John CoutureJohn Couture Posts: 370
    edited 2007-06-14 21:19
    Henry,

    I am trying to put together a course for the SX chip using SX/B. What I use as my guide is the "What's a microcontroller" book by Andy Lindsey. He does a great job of describing the concepts and then putting them into code. (grin) None of this stuff can be learned in a single day. It takes time. I always recommend to my friends that they buy the Parallax $80 kit (sold by Radio Shack) and when they are done going through that book's activities (about 40 hours), then come ask me questions.

    The thing odd about the question (and Jon's rolling eyes, I'm sure) is that ANY microcontroller can control a servo with enough patience. The microcontroller needs to output a precisely controlled pulse and there are thousands of chips that can do that.

    I choose the SX processor for my course precisely because the Basic Stamp book (i.e. What's a Microcontroller) is used in GRADE SCHOOLS (grin) and I teach at the college level. Thus, I am going to expect a little more dedication from my students and a lot less of "I'm bored, can we blow something up with this chip!" type of attitude (again tongue in cheek).

    As for your initial question, may I draw your attention to several examples of how to do it using the Basic Stamp:

    Servos - What's a Microcontroller, pg 148
    Ultrasonic Sensors - the data sheet for the sensor has a sample program
    IR Sensors - Parallax has a whole book called "IR Remote for the Boe-Bot"

    Again, all of these are in Basic Stamp PBasic which is very similar. You will find that both Jon and Bean have very clever adaptations of PBASIC code into SX/B. In return, they expect that you research how to declare variables, be able to light LEDs, read push button switches, master loops and other fundamental programming techniques. If SX/B is your FIRST programming language, then it is going to be much more difficult than learning PBASIC as a first language. This is because PBASIC is a more mature language, has much more reference material, has been adapted to classroom settings and has many independent authors that have adopted PBASIC as their language of choice. SX/B is still in its adolescent days and as such it is like a wild west outpost. (If you want to feel you are further out than that, try tackling the Propeller chip, that one is still in the pre-school stages smile.gif.

    Bottom Line: If you master the What's a Microcontroller book, I guarantee that you will be able to master SX/B in due time. The ones that have the most difficulty are the ones that want to skip all of the "baby steps".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • marlord0marlord0 Posts: 8
    edited 2007-06-18 16:58
    I have made a stabilizer for a remote control plane using BS2 and I am planing on changing it to SX chip because it is cheaper, especially if I want to make more things like that.

    so my question is about how easy it would be to transfer the BS2 code to the SX code (assembly right?), like what would be some of the things I would have to do BS2 to transfer
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2007-06-18 17:11
    If you want to make porting over your code from the BS2 to the SX a little easier take a look at the SX/B compiler. There are some differences you'll have to adjust to but overall the transision ahould not be too bad. Once there you can examine the output of the SX/B compiler (the ASM source code) and you can learn assembly for greater control and performance of your program. Be sure to checkout the help file included with SX/B as there are some great examples there.

    Good luck,

    Robert
Sign In or Register to comment.