Shop OBEX P1 Docs P2 Docs Learn Events
Need help trying to get one program to use another to print to LCD???? — Parallax Forums

Need help trying to get one program to use another to print to LCD????

mikedivmikediv Posts: 825
edited 2009-10-23 23:28 in Propeller 1
Hi guys I have 2 programs one is Andy Lindsay prop (((PstDisplayResistance.spin)) the other is LCD code I found in the Obex downloads. By themselves they both work just fine but I am trying to modify (((PstDisplayResistance.spin)) to print to an LCD instead of the PST ..

I first tried by making the LCD an Object and tried calling it from inside,(((PstDisplayResistance.spin)) no luck , I then tried tying them together no luck can anyone take a look at what I have and guide me please as usual thank you all for any help.


I had to attach them as files becuase when I tried to do a cut and paste it looked awful. I could also use some advice on how to post code from cut and paste that would look decent?

Comments

  • James LongJames Long Posts: 1,181
    edited 2009-10-23 01:43
    mikediv said...
    Hi guys I have 2 programs one is Andy Lindsay prop (((PstDisplayResistance.spin)) the other is LCD code I found in the Obex downloads. By themselves they both work just fine but I am trying to modify (((PstDisplayResistance.spin)) to print to an LCD instead of the PST ..

    I first tried by making the LCD an Object and tried calling it from inside,(((PstDisplayResistance.spin)) no luck , I then tried tying them together no luck can anyone take a look at what I have and guide me please as usual thank you all for any help.


    I had to attach them as files becuase when I tried to do a cut and paste it looked awful. I could also use some advice on how to post code from cut and paste that would look decent?

    I'll let the usual guru's help with the slicing....since I have to ask a bunch myself.....

    The code must be put between
    [noparse][[/noparse]code] tags [noparse][[/noparse] /code]  <----notice the extra space in there to let the tag show.
    

    This is the only way to preserve the spacing.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!

    Post Edited (James Long) : 10/23/2009 3:38:21 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-23 06:40
    Hello Mike,

    your LCD has a serial interface for controlling it.

    Somehow the serial bitbanging towards the LCD has to be done.
    This is done by a serial driver who cares about the details of the bitbanging
    so you don't have to care about them.

    In this case this is done by the oject "FullDuplexSerialPlus" short FDX+

    LCD.SPIN uses FDX+
    and PstDisplayResistance.spin uses FDX+

    LCD.SPIN was made to communicate with an LCD which works at 9600 baud which is connected to PIN 15
    and the code LCD.SPIN starts the serial driver FDX+ with the parameters mentioned above

    CON
      pinLCD = 15
    
    PUB StartLCD
    ...
     LCD.start(24, pinLCD, 0, 9600)
    
    
    



    PstDisplayResistance.spin was coded to communicate with the PST.EXE over the Propplug (which use PIN 31,30 at 57600 baud

      debug.Start(31, 30, 0, 57600)              ' Start FullDuplexSerialPlus
    
    



    the serial driver is your butler you call for "serving serial data" whatever the serial dat might be

    Now I assume you want the LCD to show a resistance-value
    therefore you DON'T need the PstRcDisplay.spin-file

    You need the object that measures the resistance which is "RcResistance.spin"

    and a PART of the code-LINES of PstDisplayResistance.spin

    PUB Update(resistance) | strPtr                      ' Display resistance value
      'strPtr := fs.FloatToString(resistance)
      debug.tx(debug#HOME)
      debug.Str(String("R = "))
      debug.dec(resistance)
      'debug.Str(strPtr)
      debug.tx(debug#CLREOL)
    
    



    the pub Update does the details to clear display show a title "R =" and show the value
    in PstDisplayResistance.spin the serialdriver-object FDX+ has the name "debug"

    if you put this code into your LCD.spin you have to rename the codelines that
    they match with the name of the FDX+-object in your file LCD.spin which is

    OBJ
      LCD    : "FullDuplexSerialPlus"
    
    



    so to add the Pub update to LCD.SPIN it looks like this
    but as R is delivered as Floating-point-value you have to use FloatToString

    and add the floatstring-object to your code

    OBJ
      fs      : "FloatString"
    
    



    PUB Update(resistance) | strPtr                      ' Display resistance value
      strPtr := fs.FloatToString(resistance)
      LCD.tx(debug#HOME)
      LCD.Str(String("R = "))
      LCD.Str(strPtr)
      LCD.tx(debug#CLREOL)
    
    



    and somewhere you have to add the measuring of the resistance itself

    OBJ
      meter   : "RcResistance"                   ' MeasureTime.ASM is also an option
    
    PUB Measure_Resistance                                               
      repeat                                     ' Repeat loop
        R := meter.Resistance                    ' Get resistance
        waitcnt(clkfreq/10 + cnt)                ' Display refresh 10 Hz
        Update(R)                             ' Update display
    
    



    The code above are only code-snippets to show the principle it is not enough to copy & paste them together
    try it and if it does not work come back with any questions you like

    best regards

    Stefan

    Post Edited (StefanL38) : 10/23/2009 7:03:37 AM GMT
  • mikedivmikediv Posts: 825
    edited 2009-10-23 22:43
    Stefan thank you for always jumping in and helping , I really like the way to teach to fish instead of just eating for day LOL no really I am trying so hard to learn Spin I love this stuff and if I can program it opens a whole world of projects to me.
    I am trying my best to digest this and will certainly have a question or two if you do not mind going forward just one for now I am not familiar with FDX+ can you give me the meaning? Does FDX+ refer to the fullduplexplus driver?
    I am sorry I re-read your document and found it

    Thank you

    Oh James did you have a code formater ? for was it clusso?

    Post Edited (mikediv) : 10/23/2009 10:57:34 PM GMT
  • James LongJames Long Posts: 1,181
    edited 2009-10-23 22:47
    mikediv said...
    Stefan thank you for always jumping in and helping , I really like the way to teach to fish instead of just eating for day LOL no really I am trying so hard to learn Spin I love this stuff and if I can program it opens a whole world of projects to me.
    I am trying my best to digest this and will certainly have a question or two if you do not mind going forward just one for now I am not familiar with FDX+ can you give me the meaning? Does FDX+ refer to the fullduplexplus driver?
    Thank you

    Oh James did you have a code formater ? for was it clusso?

    Nope wasn't me....I'm not that deep into programming......must have been Clusso.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-23 23:28
    Hello Mike,

    Yes I realy enjoy helping. (not much postings today I'm a little bored)

    here is the code formatter it is from PhiPi.

    Yes FDX+ is the short name for the F)ull-D)uplex-S)erial-Plus-driver (File FullDuplexSerialPlus.SPIN)

    stored in folder C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\PE Kit\6 - Objects Lab\FullDuplexSerialPlus.spin

    best regards

    Stefan
Sign In or Register to comment.