74hc595 with four 7 Segment LEDs HDSP-5723 #5147
Replies: 1 comment
-
Posted at 2015-09-06 by alexanderbrevig Hi! Looking good! :) The easiest way for you to optimize is to cut down on white space. I think Espruino minimizes stuff slightly but if you don't optimize run-time you will optimize mental time and maybe even a few calories from having to scroll less ;) Btw @gfwilliams, does Espruino support the ECMAScript 6 standard of the Posted at 2015-09-07 by @allObjects NP... But before going there, are you sure you want to burn cycles for the multiplexing? I'd reather spend another 3 x 39 cts and send the data all at once to the daisy chained 74HC595. With 4 x 73HC595, create a string (which handles all your divs and mods), take the ascii vals of the chars and point adjusted into a table with your bits for segments (as you already do with z[])... something like this (assuming positive integer):
You can go even further including:
If you do not like Using a predefined UInt8Array, you can even still keep the multiplexing and do some 'efficient' display. Your display may dim and with changing in brightness, show digits in different brightness, and - worst - get stuck on a digit when Espruino does some other non-interuptable thing and cannot handle the mux timer timely. Do not use the setInterval(), but more so the setTimeout(), to indicate that your muxing is not 'really' to a beat. For example something like this:
You notice that the conversion form integer to the bit/segment patterns values in digs[] happens only once at every invocation of displayInt() and independent on the actual multiplexed displaying by muxDsp. Each digit is displayed one after the other in self-re-invocating muxDsp(). Something that Espruino is really cool in: ...being event driven. NOTE: Driving for the common cathode can be done with simple NPN transistor or ULN2003. Instead of current limiting resistors on the anodes, you can use PWMs to drive the pull downs at the common cathode and choose a duty cycle that does not make the power consumption exceed the display segments limit - watch the inversion... :). Connecting the My preferred HW would have 4 * 74HC595, a pwm pin connected to _OE, HDSP-5723 common cathodes grounded, and no SPI nss_pin used. A related SW for invocation with, for example,
...next thing is to make a module out of it using the typical connect()-pattern: Having a module, it makes sense to have brightness as a connect and runtime option. Useful additional connect options to consider are: leading 0, no leading 0, leading or trailing negative sign, etc. Extending the display for strings to map as many alphanumeric character as reasonably readable on 7-segment display will make it a versatile and useful - and may be a bit bloated - module). PS: code only partially tested... ;) Posted at 2015-09-07 by DrAzzy nss_pin to OE won't do what you want. OE is active low, and nss_pin goes low, so that would only enable the outputs while you were putting data into them, instead of the other way around. Posted at 2015-09-07 by @allObjects noticed that and updated to ...nss_pin inverted on _OE.. But thanks anyway. Posted at 2015-09-07 by @gfwilliams Looks good!
Yes - so that could be a bit easier to read. Also...
Hope that helps! Posted at 2015-11-15 by werty1st Hello friends, thank you for you suggestions.
I have chained three additional 74HC595 s. The problem with that solution is, that i have no clue how to bring all this wires to a PCB breadboard. I think i will have to do it the multiplexing way to avoid all this new cables. Attachments: Posted at 2015-11-16 by @gfwilliams Wow, that's great! A lot of wires there!! Posted at 2015-11-16 by @allObjects The 'all-you-can-eat wire-buffet' hints the use of a dedicated peripheral display that includes the logic to receive by, for example I2c, SPI, etc. and do the multiplexing. ...if the display is not the only thing you want to show case (educationally). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-09-06 by werty1st
Hi,
can someone review my code? i think that there must be a more efficient way to get this done.
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions