Shop OBEX P1 Docs P2 Docs Learn Events
Prop and a 74HC595 driving a single 7 segment display. — Parallax Forums

Prop and a 74HC595 driving a single 7 segment display.

eagletalontimeagletalontim Posts: 1,399
edited 2013-09-01 09:30 in Propeller 1
Hello to all once again! I am tinkering with another project and have a question about the 74HC595. Is there a way maximum distance the serial data can be pushed to the 595? The reason why I ask is because my main circuit will be tucked away in a closet, but I would like to have the display mounted somewhere outside the closet, probably about 4 feet away from the main brain. I am making a circuit board that will have a surface mount 14 pin socket that will hold the display and on the opposite side, I need some sort of standard jack that will be plugged up via a standard data cable of some sort. I was hoping to use a USB cable, but I want to make sure it will work before I order some USB jacks. All I need is 5 wires and a standard USB has 4 internal plus the common shield which I hope to use as the ground.

Comments

  • Hal AlbachHal Albach Posts: 747
    edited 2013-08-31 07:20
    Many people consider using the shield as a current carrying conductor to be bad practice. Have you considered using a cat-5 patch cable? You can use one pair for power and ground, and use the other three pairs by using the solid color wire for signals and the other wire of each twisted pair as a shield, grounding at one end only. Also, you won't have to order anything, you can get all the cat-5 stuff you need at Home Depot or Lowe's.
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-08-31 07:53
    micro-usb is 5 wires as there is one extra for Id ,used for usb otg,
    try to use the wires in an order that if someone by mistake plug in a real usb host nothing bad happens
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-08-31 10:39
    I am brain-storming for a different type of plug because if this ever gets hooked up to a computer on accident, I don't want to fry anything. (I am prone to doing something like that, or my kids may try it....) I need a standard made cable that is small, flexible, and has 5 connections that does not hook up to a computer. I do agree on the shield too, but that is what I was thinking at the time for something that would work temporarily. If I ever build some for friends, I don't want them to hook it up wrong either. Cat5 was my original idea, but the wiring is not the same at both ends so the cable would have to be plugged up one specific way.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-08-31 10:55
    Cat5 was my original idea, but the wiring is not the same at both ends so the cable would have to be plugged up one specific way.

    Cat5 is a wire type not a connector type. But I think I know what you mean. Most ethernet cable has the same wire order on the connectors. There are exceptions (I think one is a crossover wire) but most ethernet cables use the same wire order on both connectors.

    There's also the possibility of using six wire phone line.

    SparkFun sells sockets for both RJ-45 and the phone connectors (I don't recall the RJ number).

    In my mood enhancing LED project I used ethernet cable to carry the Prop's 3.3V logic about ten feet. I'm pretty sure others on the forum have used it to carry 3.3V much further.

    Edit: It was a 9 foot cable. Here's some discussion about using Cat5 to carry Prop logic.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-08-31 11:03
    Maybe I was thinking of a crossover cable... I do have some surface mount Ethernet connections on hand. DipTrace does not have the pattern for the jack in their library so I have to modify a design and hope it works....
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-08-31 21:52
    Does having 4 wires instead of 5 help? Since this is a single-digit display and you are not multiplexing then you don't really need an output latch but since you are already using the 595 then just tie the output latch clock to the data input line and it doesn't matter if the output changes while you are still clocking in the data, just simply pulse the data line after the transfer to make sure the latch is updated. This saves one extra line and does not affect the operation of the display as it is only a single digit and won't be affected by ghosting. Now you can look at standard 4-wire connectors, perhaps even the A/V barrel jacks that are used.

    BTW, this kind of distance is no problem really but make sure the 595 has a decoupling capacitor and add one to the clock line, just a small 100pf or so to filter out any transients from upsetting the display.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-08-31 22:23
    I do have it connected as you have described, but the quick flashing of the LED's during a display change is kind of annoying so I added a separate line that controls the OE (Output Enable) on the chip. It turns off the output for a brief period while the 595 is receiving the next display pattern. I am still thinking a 6 wire phone line would be perfect since the wire is small and flexible. I just need to locate a surface mount jack and some premade cables.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-08-31 23:09
    I do have it connected as you have described, but the quick flashing of the LED's during a display change is kind of annoying so I added a separate line that controls the OE (Output Enable) on the chip. It turns off the output for a brief period while the 595 is receiving the next display pattern. I am still thinking a 6 wire phone line would be perfect since the wire is small and flexible. I just need to locate a surface mount jack and some premade cables.

    I'd think you'd be better off using the latch rather than the enable to avoid the flashing LEDs. Using the enable, you'll end up turning all the leds off during the transition while the latch would let you change from one set of LEDs to the next without flashes or having it turn off.

    On the other hand, having control of the enable can be useful if you want to control the brightness of the display. You can use PWM on the enable pin to control the brightness. If you use the enable to control brightness then I'd stick with your current configuration but if you're going to leave the LEDs at full brightness, then use the latch pin to control your transitions.

    By using a faster driver, you should be able to use the latch as Peter suggests without seeing any noticeable flashes.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-08-31 23:18
    I do have it connected as you have described, but the quick flashing of the LED's during a display change is kind of annoying so I added a separate line that controls the OE (Output Enable) on the chip. It turns off the output for a brief period while the 595 is receiving the next display pattern. I am still thinking a 6 wire phone line would be perfect since the wire is small and flexible. I just need to locate a surface mount jack and some premade cables.
    It sounds like the serial clock rate must be very very slow or else you are updating the LEDs much too often anyway, you would never need more than 10Hz. An I2C I/O port would have been easier I would have thought. Your output latch clock (not data clock) can be driven from the clock line using an NPN + resistor + cap to effect a clock line that only clocks once the data clock has settled low so it becomes an automatic output latch update clock. I love those RTS barrel jacks as they are so compact and you only need to drill a simple hole in your casing. I also use 10-way IDC headers as they are quite compact and easy to terminate too plus you can have each alternate wire as shields.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-09-01 07:30
    I do like having control over the OE since I do plan on using PWM on that pin, but I have not figured that out yet. I was going to go I2C, but I was not sure how to use PWM with I2C. The clock is driving by pin 15 on the prop and the code is in Spin since that is all I know right now. I am learning the coding slowly, but things are making more sense as I keep working with it. Here is the code that I have right now. It is only a test program to make the display work....
    con
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      oe = 12 
    
    obj
      BS2 : "BS2_Functions"
      leds : "jw_595_ez"
      
    
    pub main | n, i, pattern
    
      leds.init(15, 14, 13)                                            ' initialize 595 driver - Pin 14 is not used, need to recode to open pin for later use.
      dira[oe]~~
    
      repeat
        repeat n from 1 to 4
          pattern := numbers[n]
          outa[oe] := 1
          repeat i from 0 to 8
            leds.out(pattern, true)
            pattern >>= 1
            waitcnt(400 + cnt)
          outa[oe] := 0
          waitcnt(100_000_000 + cnt)
    
    DAT
      numbers byte %1011_1110, %0000_0110, %0111_1100, %0101_1110, %1100_0110
    
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-09-01 07:52
    No need for enable to be used.
    Only time is of you multiplex and you want a all-off in between each plex as sometimes the common cathode switching creates a bleed over.

    And as the Prop is so fast you could use a 74HC164 that don't have a latch and only 2 wires is needed,
    you clock the 8 bits out fast (in less than 1ms) and it will not be visible to the human eye that the whole sequence went thru all the segments.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-09-01 08:24
    I would like to use a latch because I don't want to tie up a cog just to run the display. I would like to just call the display function, set the digit I want to display and the 595 keep the memory of what needs to be displayed. The PWM would have to be a cog, but I would like to be able to run at least 2 PWM pins on demand. I don't know how reliable it would be, but I was thinking a cog that would continually loop using the CTRA as the counter. If I want one pin to pulse at half the rate of the other, I would simply skip one loop, then enable the pin on the second loop....if that makes any sense :p

    Btw, the display is a common Anode.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-09-01 08:33
    I would like to use a latch because I don't want to tie up a cog just to run the display. I would like to just call the display function, set the digit I want to display and the 595 keep the memory of what needs to be displayed. The PWM would have to be a cog, but I would like to be able to run at least 2 PWM pins on demand. I don't know how reliable it would be, but I was thinking a cog that would continually loop using the CTRA as the counter. If I want one pin to pulse at half the rate of the other, I would simply skip one loop, then enable the pin on the second loop....if that makes any sense :p

    Btw, the display is a common Anode.

    A shift register is already a register (latched), the output latch is only there to capture the state of the register once it's done shifting. While PWM is "nice" it isn't really necessary is it? Just get it working.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2013-09-01 08:37
    The display is working as desired, I was just needing to get a better jack configuration so I could mount it in another area easily. I think the 6 wire phone jack is my best bet at this time. The PWM is my next step.

    **** EDIT : The PWM would be very nice as a red display is not as bright as a blue display and I would like to dim the display according to the surrounding area lighting. If it is a dark room, a super bright LED display is not necessary. It is not a MUST have, but this is something I have not dabbled with and is a great opportunity for some hands on learning :)
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-09-01 09:13
    >I would like to use a latch because I don't want to tie up a cog just to run the display
    No need to tie up a cog, the data will stay solid after the last clk pulse sent on the hc164.
    And because you always send 8 clks, no need to use master reset as any "bad" data will be shifted out fast.

    But the 595's latch is nicer if you have the pins available.
    PWM dimming could be done in two ways,
    a master dimming of common anode/cathode with a mosfet or use enable on the 595, though using a single counter pdm could be to fast.
    So may have to use both counters overlapping each other with slower square wave with a result of a 0% to 50% range. (OE is active low)

    Second options is sending zero (clear) data 60 times second and the pause lenght from the last real data sent will set the brightness desired.
    The last option will tie up a cog as timings can not vary to much, but plenty of free time in between for the cog to do other things.
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-09-01 09:30
    I've attached an object I wrote for doing PWM on 16 channels using two 74x595 shift registers. You can use it as is, but you'll have to write a shell method to map your display (assuming digits) and brightness values, as the object treats outputs as 16 discrete elements.

    This code was used in a neat animatronics project by my friend Matt (Character Dynamics)
    -- http://www.youtube.com/watch?feature=player_detailpage&v=K6V8QTdXo08&list=PLwex4JXm4a3HzJNkk9fYquGB6PTHGNYwG

    The radio (in foreground, left side of screen) has a Propeller-based controller that runs the Nixie tubes and does LED control with the 595 PWM driver.
Sign In or Register to comment.