Shop OBEX P1 Docs P2 Docs Learn Events
serout to vfd — Parallax Forums

serout to vfd

GabrielrotoGabrielroto Posts: 7
edited 2008-10-30 17:31 in BASIC Stamp
I have a vfd (vacuum fluorescent display) that will accept serial strings from the BS2P. Like this SEROUT disp,16429,[noparse][[/noparse]"Hello World"]. I would like to serout a the contents of a variable but I'm not sure how. For instance: If the debug screen says adcres = 2500 then I want the 2500 to show on my vfd screen. Here's what I have so far.
HIGH cs

MAINIO

main:
DO

LOW cs
SHIFTIN dout, clk, MSBPRE, [noparse][[/noparse]adcRes\13] ' shiftin bits from 12 bit ADC
HIGH cs
adcres= adcres-6247*10
DEBUG adcRes,CR
SEROUT disp,16429,[noparse][[/noparse]adcRes] ' Trouble Here!!!!!!!!!!
PAUSE 100
GOTO main

LOOP
END

I want

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-30 14:02
    Gabrielroto -

    See if this gives you what you want:

    SEROUT disp,16429, [noparse][[/noparse]DEC 4 adcRes]

    Check the syntax of the formatters (DEC is just one of many) either in the PBASIC Help File (within the IDE), or in the PBASIC Reference manual. Unfortunately I don't have either resource handy - sorry.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • GabrielrotoGabrielroto Posts: 7
    edited 2008-10-30 14:46
    Is it possible for me to format the 2500 as 25.00 without writing code for each individual digit?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-10-30 14:46
    Gabriel,

    As a note you would not be getting an output adcres = 2500 with the code you posted. The DEBUG screen would also have garbage using that format because you’re sending a raw binary value to it, rather than an ASCII string. The DEC formatter will work on both the DEBUG and SEROUT commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • GabrielrotoGabrielroto Posts: 7
    edited 2008-10-30 14:59
    yep, that's exactly what was happening before. I took bruce's advice and did some research on serout/DEC. I have some code that does the whole 00.00 thing, but it's a little long. If I can, I'd like to learn a shorter way to go about doing this. I have a load cell and when I squeeze it I want the numbers to go up and down in this stop watch (00.00) kind of format. I figured out that 88 (8.8*10) is equal to one pound of pressure so I'm still working on that math too. Anyhow thanks for all you guy's help.
  • RDL2004RDL2004 Posts: 2,554
    edited 2008-10-30 17:31
    This is the best way I could figure out how to do it for a temperature display. I only showed to one decimal place.
    This was for an LCD so I added a leading space when the temp is under 100 degrees to keep things lined up.

    IF ( Temp > 999) THEN
      SEROUT TxPin, Baud9600, [noparse][[/noparse]DEC Temp DIG 3, DEC Temp DIG 2, DEC Temp DIG 1, ".", DEC1 Temp]
    ELSE
      SEROUT TxPin, Baud9600, [noparse][[/noparse]" ", DEC Temp DIG 2, DEC Temp DIG 1, ".", DEC1 Temp]
    ENDIF
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
Sign In or Register to comment.