Shop OBEX P1 Docs P2 Docs Learn Events
Help Getting Started with PING in the SX/B Environment — Parallax Forums

Help Getting Started with PING in the SX/B Environment

Bill ChennaultBill Chennault Posts: 1,198
edited 2010-01-03 16:13 in General Discussion
All--

It has been a while since I cut any SX/B code. (Plus, even when I did I was a novice.) And, I have never used PING. I am trying to get my PING (which has languished on the shelf for months) up under SX/B on an SX48 with a 20MHz resonator.

If you have it, will you kindly post a piece of code that will launch me in the right direction? (I have the BS2 sample code and tried to modify that into existence and failed.)

Thanks and Happy New Year!

--Bill

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.

Comments

  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-12-29 21:51
    Here's a dirt-simple bit of code. It needs an SX-Key, though, as program output is through Debug.

    Note: You have to change the extension -- the silly forum software wouldn't let me attache a .SXB file for some reason....
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-12-29 22:05
    JonnyMac--

    That looks exactly like what I need. I was surprised by the lack of PULSIN/PULSOUT in your example, but I am confident your method is superior.

    Thank you, as always.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-12-29 22:10
    JonnyMac--

    Guess how this line compiled! [noparse]:)[/noparse]

    result = result >> 1

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-12-29 23:45
    Don't know... the program compiles fine on my system. Are you using the latest version of SX/B? (it has to be manually installed). I've attached the .SRC file for your inspection (you can also run this from the IDE). Again... I had to change the extension to .txt. Oi.....
  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-12-29 23:56
    BTW... the reason for now PULSIN is so that I can use a conditional compilation constant to set the units and now have to use division after; faster, and generates less code. You can't always do this, but in the case there PAUSE and PAUSEUS allow for fractional values it made sense.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-12-30 00:48
    JonnyMac--

    (--> translated into HTML [noparse]:)[/noparse] )

    I am having trouble getting Debug to work for me. It is doubtless due to my ignorance. Instead of a long, detailed explanation, I bet this screen shot will tell you exactly what I am going wrong. (I am using one of Robert D.'s·SX48 modules.) Debug doesn't DO anything. It just sits there as soon as I start it with the grayed out areas that I THINK should be active.

    SXBDEBUG.JPG

    I cranked it up per the instructions in your book . . . I think!

    Thanks!

    --Bill



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.

    Post Edited (Bill Chennault) : 12/30/2009 3:19:51 AM GMT
  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-12-30 00:54
    Are you using a USB SX-Key -- those have had some problems with Debug. We (EFX-TEK) found we had to pull the 10K resistor that connects to the OSC1 and OCS2 pins. And make sure you don't have a resonator inserted; in Debug the Key generates the clock.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-12-30 02:53
    JonnyMac--

    Yes, I am using a USB Key and I COMPLETELY FORGOT about the resonator having to be removed for Debug to work! As soon as I yanked it out of the bottom side of the SX48 module, Debug came to life.

    However, I could not get PING to come to life, although the green LED did light. When I did a Debug-->Run, the Debug screens did pretty much nothing. It was only when I slowed it to a walk that the Debug screens became animated. But, no joy with PING.

    Here is some simple code I used to prove to myself that Debug and Watch was working properly . . .

    ***************************

    ' HowDoesDebugWork.SXB

    DEVICE·SX48,OSCHS1
    FREQ·20_000_000
    temp·var·byte

    Program Start

    Start:
    · for temp = 0 to 255
    ·· ·watch temp, 8, ubin
    ····break
    · Next
    · Goto Start

    ***************************

    I suppose my next step will be to drop back to the sample code using a BS2 on a Board of Education.

    --Bill
    ps Sorry about that wide picture. I fixed it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.

    Post Edited (Bill Chennault) : 12/30/2009 3:20:48 AM GMT
  • JonnyMacJonnyMac Posts: 9,211
    edited 2009-12-30 14:32
    Yep, make sure you have a good Ping))). I've used the code I sent you many times with no troubles.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-01 23:32
    JonnyMac--

    Forgive me for not reporting results sooner.

    PING is good, as I finally went to a BS2px24 and the demo code worked fine. I then stuck in a NEW BS2p40 and the demo code worked fine. I THINK the problem in the SX environment might be that I am using one of Robot Workshop's great SX48 modules, which is a drop-in replacement for a BS2p40 (pin wise) and your code was written for the SX28 environment.

    Could the subtle differences between the two SX implementations (SX48 module vs. SX28) give one with my inexperience problems? Additionally, the way I read the parallel LCD·schematic hookup documentation in the Parallax literature, there are four 10k ohm pull down resistors; one each on P4, P5, P6, and P7. There is also one 4.7k ohm pull down resistor on P0. (I changed the code to reflect P0-->E instead of P1-->E.)

    Am I readiing the schematic correctly and these resistors SHOULD be added as shown, or are they built into the X1 area of the PDB?

    Tomorrow's efforts will be with an SX28 instead of the SX48 module. I THINK the SX28, SX-Key, and PDB are what was used to develop the code. (?)

    Thank you for helping me.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.

    Post Edited (Bill Chennault) : 1/1/2010 11:37:20 PM GMT
  • Shawn LoweShawn Lowe Posts: 635
    edited 2010-01-02 16:14
    Jon's code was written for a sx28. I dont know what else you would have to change other than the processor declaration.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-02 21:38
    Shawn--

    Thank you!

    I agree. Soon I will get back to using a plain SX28 with my working circuit duplicated from the Stamp environment on a PDB to the SX28 environment on the PDB.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-02 22:36
    JonnyMac and Shawn and All--

    Once I put the correct resistors in place, the code worked with an SX28 exactly like it was supposed to. I can't thank you enough.

    But, tell me . . . The Parallax parallel LCD documentation clearly says to use 10k ohm resistors, which I did, unsuccessfully. Stamp Works (p75) clearly shows 220 ohm resistors, which I used successfully.

    Am I SOMEHOW reading the Parallax LCD documentation wrong concerning the 10k ohm resistors?

    Now, I need to skin the demo code functionality down to·only what I need to display: Output from PING. (And get it working on Robert Doerr's SX48 module.)

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-02 23:48
    JonnyMac and Shawn and Robert Doerr--

    I have the LCD module up and running on Robert's SX48 module! All along it was the resistor values due to the difference in the LCD schematic (10k ohm; wrong) and the Stamp Works schematic (220 ohm; correct).

    Robert, these are truly great modules that make SX life even easier when using Bean's incredible compiler and JonnyMac's Practical SX/B (No Assembly Required).

    Note to Bean: Create some LCD and other display commands! The SX is nowhere near dead.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • JonnyMacJonnyMac Posts: 9,211
    edited 2010-01-03 04:35
    Bill:

    Have a look at the code attached to this post for parallel LCD stuff on the SX: http://forums.parallax.com/showthread.php?p=819481

    The LCD data lines are either driven by the SX or by the display (in read mode) so there is no need for the 10K pull-downs. It is a good idea to use a pull-down on the E line to prevent garbage in the display when the SX is in reset (IOs floating).

    Post Edited (JonnyMac) : 1/3/2010 4:58:51 AM GMT
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-03 15:32
    JonnyMac--

    Gee. I'm glad I don't have to drive in California! My reactions are nowhere near as quick as yours!

    I'm studying the code.

    The 10k resistors did not work. The 220 ohm resistors do work. However, I wonder if I can just do away with the 220 ohm resistors? I'll give that a try. (I'll keep the 4.7k pull-down resistor on Enable.)

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2010-01-03 16:13
    All--

    The 2x16 parallel LCD works just fine without the 220 ohm pull-down resistors.

    In the name of accuracy, although the 2x16 LCD documentation shows 10k ohm pull down resistors on DB4, DB5, DB6, and DB7, plus a 4.7k ohm pull-down resistor on Enable, Stamp Works shows only a SINGLE pull-down resistor, located on Enable. Both JonnyMac (above) and Robert Doerr (PM) mentioned that pull-down resistors were not necessary on DB-4-DB7. However, Stamp Works ALSO shows 220 ohm in-line resistors between the Stamp pins and DB4-DB7.

    The 2x16 LCD seems to work fine without them.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
Sign In or Register to comment.