Shop OBEX P1 Docs P2 Docs Learn Events
A question on the SX — Parallax Forums

A question on the SX

GeorgeLGeorgeL Posts: 131
edited 2009-03-07 19:59 in General Discussion
I am coming here from the BASIC STAMP and want to use the SX chips instead (cost effectivenes).
I was looking at the SX starter kit on Parallax's store and saw that theres two SX chips included. Does this mean they are non-rewritable? How much EEPROM does the SX chip have?

Aside from chips, what is teh cheapest method of finding the distance between two robots? They are communicating via iR.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-06 03:44
    The amount of EEPROM depends on the SX model. The smallest is 2K and the largest is 4K. This is in terms of 12 bit instructions.

    The EEPROM, like all EEPROMs is rewritable.

    The cheapest method of finding the distance between two robots is probably to use a tape measure.

    You can use IR to measure distances, but it works better measuring the distance to large objects like walls or furniture, particularly for longer distances, on the order of several feet or more.

    You can use ultrasound, like the PING))). This is not much different from IR in that it works better for larger objects, particularly when measuring longer distances.

    The reasons for choosing one over the other is mostly a matter of the reflectivity of the objects. Some things reflect IR well. Some things reflect ultrasound well. Some things don't reflect either well and it's hard to measure distances to this sort of thing.

    They're not cheap, but you could use a laser rangefinder and some kind of reflector on one robot to measure the distance provided that the robots are in direct line-of-sight of each other. The robot with the rangefinder could send a message to the other robot telling it how far away it was. It could even include the bearing using a digital compass for a reference.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-03-06 04:11
    Just a follow-up on Mike's comments; the memory space inside the SX is not rewritable at run time; it can be reprogrammed, but only through the use of the SX-Key or Blitz programmers. What this means, then, is there is no WRITE instruction as with the BASIC Stamp (which is actually writing to an external EEPROM). If you need to add an EEPROM it's pretty easy with SX/B's I2C commands. Sitting next to me on my desk is a new commercial product that uses a 64K EEPROM for storing prop control sequences. The product uses an SX28 and I programmed it in SX/B 2.0 with a bit of Assembly for "background" communications and LED control (I use a bi-color LED).
  • GeorgeLGeorgeL Posts: 131
    edited 2009-03-06 06:17
    Thanks for the info. I was originally thinking the SX was similar to those PIC chips that you need some magnet or something to reprogram. I have the PING))) and I find it very accurate. I would love to use it for my project but then I would need 10-20 of them, and thats a bit out of budget. I know there is a SX/B language or something having the word BASIC in it. Can someone give an example of a Hello World program for the SX in the simplest method? I am considering using the SX for this project, since 20 BS2 chips would cost more a bit to much let alone other parts.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-03-06 06:47
    If you crack open the SX/B help file (installed with the SX-Key IDE) you'll find lots of examples.
  • BeanBean Posts: 8,129
    edited 2009-03-06 13:33
    George, here is a simple SX/B program.
    ' SX/B code to blink LED on pin RA.0 256 times
    
     
    DEVICE SX28, OSC4MHZ, TURBO, OPTIONX, STACKX
    FREQ 4_000_000
     
    ' Define pins here
    LED    PIN RA.0 OUTPUT
     
    ' Define variables here
    temp   VAR BYTE
     
    PROGRAM Start
     
    Start:
      ' Put your code here
      FOR temp = 0 TO 255
        HIGH LED
        PAUSE 200
        LOW LED
        PAUSE 200
      NEXT
    END
     
    

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • GeorgeLGeorgeL Posts: 131
    edited 2009-03-07 06:32
    Thanks to all for the info.
    Bean that's a great example, and I found the book you got it from. Read through it and got a good sense for the language. Wondering if you could give a snippet/example on sending a value similar to a TV remote through an infrared LED, and how this would be written RCTIME irPin, 1, time

    Thanks
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-03-07 15:44
    Sending IR codes is not difficult, but not trivial, either. First, you have to know which protocol (I use Sony SIRCS). Then you have to modulate the LED (I do this internally with an interrupt). The attached program demonstrates sending Sony SIRCS codes (12- and 20-bit) using the ISR to modulate the IR LED (40kHz) and to decrement the 45ms frame timer for the IR command
  • GeorgeLGeorgeL Posts: 131
    edited 2009-03-07 18:08
    Yea, I am using Sony's system. I am wondering if you have any errors but when I try to send it to the chip, I get a long list of them.
    First two I get are
    INVALID NUMBER OF PARAMETERS

    irFrameTmr VAR Word @irTemp(0) ' IR frame timing
    irKey VAR Word @irTemp(2) ' IR key code (7/12 bits)


    Also does it keep sending codes on a loop or just once and its over?
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-03-07 18:44
    You don't have the latest version of the compiler installed -- the code is fine. Get SX/B 2.00.16 from the sticky thread at the top of this forum.

    When you take a moment to actually study the code you'll see that the TX_SIRCS and TX_SIRCS20 routines just send the SIRCS code once. The reason for this is that different devices have different requirements. For example, my Sony still camera remote sends five (20-bit) shutter commands in row to snap a picture. In an intervalometer program I wrote (see this month's issue of Nuts & Volts magazine) I duplicate that by calling TX_SIRCS20 from a loop.
  • GeorgeLGeorgeL Posts: 131
    edited 2009-03-07 19:54
    Ok. Great, it compiled. Need to learn SX/B now though.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2009-03-07 19:59
    If you've used the BASIC Stamp it won't take long -- just dig in and experiment. If you've got a PDB then you're really in great shape, especially if you want to move a project from the BS2 to the SX.

    There are lots of examples in the help file and my column in N&V for the last two years has been all SX/B -- you can find digital reprints online at Parallax.
Sign In or Register to comment.