74HC595 with led bar.

Place your projects here
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

74HC595 with led bar.

Post by Fernando Perez »

In reality, I have failed in this project, since I wanted to obtain a battery-powered system that would visually and audibly indicate the strength of the Wi-Fi signal when moving it around the house.
But this signal is so feckless and fickle that you can't pay much attention to it.
However, I publish it in case someone may find it useful for other purposes.
For example, use the analog input of the ESP8266 to move the LED bar.
image.png

Code: [Local Link Removed for Guests]

spi.setup 100000     ' set the SPI port at 100KHz
pin.mode 16, output  ' set the Pin used for CS as output
pin.mode 12, output  ' set the pin used for the buzzer

prev = 0

for i = 0 to 8
  gauge i
  pause 500
next i

for i = 8 to 0 step -1
  gauge i
  pause 500
next i

for i = 1 to 30
  x = rnd(9)
  t = convert.map(x, 0, 8, 380, 740)
  pin.tone 12, t, 50
  gauge x
  pause 250
next i

while 1
  rssi = abs(wifi.rssi)
'  percent = 150-(5/3) * rssi  
  percent = convert.map(rssi, 30, 90, 100, 0)
  percent = cint(percent)
  wlog percent

  percent = convert.map(percent, 35, 85, 0, 8)
  percent = cint(percent)
  wlog percent
  if percent <> prev then
    prev =  percent
    t = convert.map(prev, 0, 8, 380, 740)
    pin.tone 12, t, 50
    gauge percent
  end if
    
  pause 3000
wend  
  
end

SUB gauge(x)
LOCAL ledbar, r

  ledbar = (2^x) - 1
  pin(16) = 1     ' put the CS HIGH
  r = spi.byte(ledbar)
  pin(16) = 0     ' pulse the CS low then high
  pin(16) = 1

END SUB
https://www.myrapidq.it/public/barra_led_0.mp4
https://www.myrapidq.it/public/barra_led_1.mp4
You do not have the required permissions to view the files attached to this post.
gianmagna
Posts: 15
Joined: Sun Feb 14, 2021 11:47 am
Has thanked: 22 times
Been thanked: 4 times

Re: 74HC595 with led bar.

Post by gianmagna »

ola Fernando
in one of my projects with the 74c595 I had to turn the condition of the CS or Strobe (pin 16 of the wemos).
The datasheet gives it from 0 to 1 and then 0 and not vice versa.
Good job
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: 74HC595 with led bar.

Post by Fernando Perez »

Ciao Gianmagna.
I have assembled this circuit so that you can experiment and see how the 74HC595 actually works.
As you will see, I have not used the SPI instructions, since in reality this integrated does not communicate with that protocol (the example of Cicciocb does it for convenience and saving instructions), but a more didactic way, which allows to take a more complete control and see what happens. As an added value, this method allows the use of any GPIO of the microcontroller, without being restricted to the SPI communication pins.
Greetings.
image.png

Code: [Local Link Removed for Guests]

datos = 3  ' pin 14 of 74hc595 (data)  to GPIO3 of ESP-01 
clock = 0  ' pin 11 of 74hc595 (clock) to GPIO0 of ESP-01
latch = 2  ' pin 12 of 74hc595 (latch) to GPIO2 of ESP-01

pin.mode datos, output
pin.mode clock, output
pin.mode latch, output

while 1
  num = rnd(256)
  gosub led
  pause 3000
wend

END

led:
  byte$ = bin$(num)
  ' we add leading zeros so that it is always 8 long
  byte$ = string$(8-len(byte$), "0") + byte$
  wlog byte$
  
  pin(latch) = 0
  
  for i = 1 to 8   '  if bit$ = "1" then pin(datos) = 1 else pin(datos) = 0
    bit$ = mid$(byte$, i, 1)
    pin(clock) = 0
    pin(datos) = val(bit$)
    pin(clock) = 1
  next i

  pin(clock) = 0
  pin(latch) = 1
  
return
https://www.myrapidq.it/public/74hc595_0.mp4
https://www.myrapidq.it/public/74hc595_1.mp4
You do not have the required permissions to view the files attached to this post.
gianmagna
Posts: 15
Joined: Sun Feb 14, 2021 11:47 am
Has thanked: 22 times
Been thanked: 4 times

Re: 74HC595 with led bar.

Post by gianmagna »

Ola Fernando
I did a lot of work with 74hc4094 and 74hv595
i know how to use them i show you a recovery display used as a clock.
I am attaching the diagram of the display (reverse enginering) and if you want the program too
While I'm at it I try to put a video
You do not have the required permissions to view the files attached to this post.
Hendrix
Posts: 39
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 8 times

Re: 74HC595 with led bar.

Post by Hendrix »

Good idea, are these modules for sale somewhere?

Are you sure emittor and collector shouldn't be reversed?
gianmagna
Posts: 15
Joined: Sun Feb 14, 2021 11:47 am
Has thanked: 22 times
Been thanked: 4 times

Re: 74HC595 with led bar.

Post by gianmagna »

hello Hendrix
I unsoldered the displays to get to the cs and the transistors are connected like this, they have the collector to GND.
I checked SMD code 2F today and they are PNP not NPN, , sorry to be wrong is human
They are end of production cards and I have disassembled the displays, if you are in Italy or neighboring countries I can send them to you, as well as I do not think it is convenient.
You do not have the required permissions to view the files attached to this post.
Hendrix
Posts: 39
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 8 times

Re: 74HC595 with led bar.

Post by Hendrix »

Hi, yes, either emitter and collector reversed or the transistors are PNP. It must be one or the other :)

I just ordered a few of these boards, only about 2 euro's including shipping:

https://www.aliexpress.com/item/4001286 ... web201603_
You do not have the required permissions to view the files attached to this post.
gianmagna
Posts: 15
Joined: Sun Feb 14, 2021 11:47 am
Has thanked: 22 times
Been thanked: 4 times

Re: 74HC595 with led bar.

Post by gianmagna »

hello Hendrix
from the smd code are common collector PNP.
My displays are mounted on boards produced in 2001
now you can find better products
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1270 times
Contact:

Re: 74HC595 with led bar.

Post by cicciocb »

Hi all,
why you do not simply use one of these displays already supported by Annex ?

[Local Link Removed for Guests]

[Local Link Removed for Guests]

[Local Link Removed for Guests]

These displays already contains the necessary logic to manage the displays easily.
Hendrix
Posts: 39
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 8 times

Re: 74HC595 with led bar.

Post by Hendrix »

Yes, that would be easier.
Perhaps it is a good idea to have a page on the website with supported modules. Not only sensors but also application boards etc.
Post Reply