Shop OBEX P1 Docs P2 Docs Learn Events
Nixie tubes and no NIBs — Parallax Forums

Nixie tubes and no NIBs

JonathanJonathan Posts: 1,023
edited 2007-09-26 19:24 in Propeller 1
Hi All,

I am working on a project that uses Nixie tubes for the display. I have used these many times with the BS2 and with PICs. I can't seem to find the easy way to do this in Spin.

Basically, the project uses 2X 74HC595's to drive 4X 74141's, which drive the Nixie tubes. Each nixie needs 4 bits. So, for 4 digits, I need to shiftout·2 bytes.

In the past, I have used two different methods. In PBASIC, I would use the NIB capability to set the high/low nib of each byte, like:

nixSecs········ VAR···· byte
nixScLo········ VAR···· nixSecs.LOWNIB
nixScHi········ VAR···· nixSecs.HIGHNIB

SHIFTOUT DataOut, Clock, MSBFIRST, [noparse][[/noparse]nixSecs]


With a PIC, I would just shiftout the lower 4 bits of each byte, like:

shiftout DAT,CLK,1,[noparse][[/noparse]nixMinutesHi\4,nixMinsLo\4,nixSecHi\4,nixSecLo\4]

Of course, Spin does not have NIBs, so that rules out method #1. I would have thought that method #2 would work. However, using·either the BS2_Functions or SPI_Engine, it does not work correctly, like:

shift.shiftout(datPin,CLK,msbfirst,4,nixMinsTens)
shift.shiftout(datPin,CLK,msbfirst,4,nixMinsOnes)
shift.shiftout(datPin,CLK,msbfirst,4,nixSecTens)
shift.shiftout(datPin,CLK,msbfirst,4,nixSecOnes)


If I shiftout the entire word, manually setting the bits in it, it works correctly, like:

config := %1001_1101_1101_1101

shift.shiftout(datPin,CLK,msbfirst,16,config)

So essentially, what I am looking for is a way to load 4 nibs into a word, or a way to shiftout the lower 4 bits of a byte. The valid nixie codes for each digit can be stored in DATA or in a lookdown.

Many thanks, I know this is an easy thing to do.

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot

Comments

  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-25 17:35
    Looks like a a problem for DeSilva
    without knowing the exact requirements can't help much.
    The 595's are slow use 373's or 374's I can send you A handful
    if you're stuck.

    Best Regards
    Ian
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-09-25 17:44
    You can use a series of masks and shifts, use a mask:

    CON
    ·nibmask = %1111

    then use shifts (the << operator)

    shift.shiftout(datPin,CLK,msbfirst,16, (nixMinsTens & nibmask) << 12 | (nixMinsOnes & nibmask) << 8 | (nixSecTens & nibmask) << 4 | nixSecOnes & nibmask)



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • JonathanJonathan Posts: 1,023
    edited 2007-09-25 17:46
    What requirements do you need to know?

    I took a look at the '373 and 374. I don't see where they would help. The 595s are working fine as far as I can tell. Thanks for the offer of chips. If it turns out the 595s are a problem, I'll take you up on that.

    The problem is loading the word variable with four sperate nibs. I have been trying shifting bits and masks, but with no luck.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-09-25 17:48
    A brute force way of doing it would be

    DataOut := 16*(nixSecs/10) + nixSecs//10

    Where the 16* shifts the tens number left four places and the //10 separates the units number

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-09-25 18:00
    The *, / and // operators are highly ineffiecient, especially when dealing with powers of two.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • SkogsgurraSkogsgurra Posts: 231
    edited 2007-09-25 18:04
    Yes, I know. But it is simple. And time does not seem to be an issue. After all, there is a one second interval between updates.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-25 18:07
    Sorry About That Jonothan

    As an ex 68K engineer everything is about speed
    as usual I'm talking Smile your NIXES are very slow devices
    so the 595's are fine I'm talking sub 30nS transistion times!!!
    I'll just go and stick my head in the microwave.!!!
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-25 19:52
    Paul Baker (Parallax) said...
    You can use a series of masks and shifts, use a mask:

    CON
    nibmask = %1111

    then use shifts (the << operator)

    shift.shiftout(datPin,CLK,msbfirst,16, (nixMinsTens & nibmask) << 12 | (nixMinsOnes & nibmask) << 8 | (nixSecTens & nibmask) << 4 | nixSecOnes & nibmask)

    This is exactly what comes to mind, after it took me some time to understand the background of the problem, i.e. what IAN called the "requirements" smile.gif

    BTW I cannot understand what a '373 has to do with this, as it is a simple latch and not a SIPO !?

    The SHIFTOUT is no secret, you can understand it - and even adapt it to your needs
    PUB SHIFTOUT (Dpin, Cpin, Value, Mode, Bits)| bitNum
    {{
       Shift data out, master clock, for mode use ObjName#LSBFIRST, #MSBFIRST
       Clock rate is ~16Kbps.  Use at 80MHz only is recommended.
         BS2.SHIFTOUT(5,6,"B",BS2#LSBFIRST,8)
    }}
        outa[noparse][[/noparse]Dpin]:=0                                          ' Data pin = 0
        dira[noparse][[/noparse]Dpin]~~                                           ' Set data as output
        outa[noparse][[/noparse]Cpin]:=0
        dira[noparse][[/noparse]Cpin]~~
    
        If Mode == LSBFIRST                                    ' Send LSB first    
           REPEAT Bits
              outa[noparse][[/noparse]Dpin] := Value                              ' Set output
              Value := Value >> 1                              ' Shift value right
              !outa[noparse][[/noparse]Cpin]                                      ' cycle clock
              !outa[noparse][[/noparse]Cpin]
              waitcnt(1000 + cnt)                              ' delay
    
        elseIf Mode == MSBFIRST                                ' Send MSB first               
           REPEAT Bits                                                                
              outa[noparse][[/noparse]Dpin] := Value >> (bits-1)                  ' Set output           
              Value := Value << 1                              ' Shift value right    
              !outa[noparse][[/noparse]Cpin]                                      ' cycle clock          
              !outa[noparse][[/noparse]Cpin]                                                             
              waitcnt(1000 + cnt)                              ' delay                
        outa[noparse][[/noparse]Dpin]~                                            ' Set data to low
    



    The funny thing is, that Jonathan reports the "solution #2" in his first posting as "does not work"!? This is somewhat dubious...

    Post Edited (deSilva) : 9/25/2007 7:58:15 PM GMT
  • JonathanJonathan Posts: 1,023
    edited 2007-09-25 19:55
    Hi All,
    Thanks for all the help!! I got it going, here is what I wound up with:

    minsHi := 2
    minsLo := 3
    secsHi := 4
    secsLo := 5
     
    nixMinTens := lookupz(minsHi: %1000,%0000,%0001,%1001,%0010,%0011,%0100,%0101,%1101,%1100)
    nixMinOnes := lookupz(minsLo: %1000,%0000,%0001,%1001,%0010,%0011,%0100,%0101,%1101,%1100)
    nixSecTens := lookupz(secsHi: %1000,%0000,%0001,%1001,%0010,%0011,%0100,%0101,%1101,%1100)
    nixSecOnes := lookupz(secsLo: %1000,%0000,%0001,%1001,%0010,%0011,%0100,%0101,%1101,%1100)
    time := (nixMinTens & nibmask) << 12 | (nixMinOnes & nibmask) << 8 | (nixSecTens & nibmask) << 4 | nixSecOnes & nibmask
     
    dira[noparse][[/noparse]latch] := 1
    outa[noparse][[/noparse]latch] := 0
     
    repeat
      shift.shiftout(datPin,CLK,lsbfirst,16,time)
      outa[noparse][[/noparse]latch] := 1
      wait_ms(10)
      outa[noparse][[/noparse]latch] := 0
      wait_ms(100)
    
    

    I still wonder why method #2 from above won't work. Any ideas?

    Many thanks for the help. Paul, I was working on something similar, but was not using the pipe. Good thing to know about.

    Ian, as noted, I have a 1 sec epoch, so speed isn't an issue. Thanks for the kind offer though!

    I bet I'm the first person to drive Nixies with a Prop! :-)

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-25 20:04
    Jonathan said...
    I still wonder why method #2 from above won't work. Any ideas?

    Yes, there is some difference between LSBFIRST and MSBFIRST.

    I feel a little bit "put on". In fact you gave NOT your "requirements" in the first place!!
  • JonathanJonathan Posts: 1,023
    edited 2007-09-25 20:13
    DeSilva,

    I'm very sorry if you feel "put on". I did set out the requirements to the best of my (limited) abilities. Why does it make a big difference? It only reverses the display, but I don't see where it really changes the "requirements".

    Sorry and thanks for the help!

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-25 22:46
    Unfair DeSilva
    Just to be sure looked @ the spec sheet the 595 is a 373 with an O/P
    latch.

    Best Regards Ian
    :- This a comment about me and nobody else
    please engage brain before operating computer.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-25 22:52
    Maybe we have different datasheets in Germany wink.gif
  • IAN STROMEIAN STROME Posts: 49
    edited 2007-09-26 19:24
    No I'm sure
    you don't,my fault totally, read the wrong page
    looked at it again today and felt a total pratt.

    Many many apologies

    Best Regards Ian
Sign In or Register to comment.