Page 1 of 1
7 seg display
Posted: Sun Mar 16, 2025 9:34 am
by peterhalloway
Weird one this. Works as expected in simulation but when I program the board the 7 segment display has "8" illuminated. If you press a digit on the keypad, the correct digit displays but as soon as you remove your finger 8 is illuminated again.
It is such a simple program surely this is a bug and not a hardware issue?
Pete
Re: 7 seg display
Posted: Sun Mar 16, 2025 9:56 am
by chipfryer27
Hi
I notice your Keyboard and LED display both share the same B1 pin which will lead to issues, but probably not as you describe.
How is your LED display connected? It sounds more connectivity rather than bug, perhaps to do with common pin especially if using a transistor, or perhaps Weak Pull Ups enabled where they shouldn't?
Schematic would be a big help, or sketch.
Regards
PS
Also, I see you are using a Common Pin. This is usually only needed when switching between multiple displays (multiplexing) and is not needed here. Without seeing schematic, perhaps connect cathode directly to 0v and set Common Pin to No?
Re: 7 seg display
Posted: Sun Mar 16, 2025 11:33 am
by mnfisher
The other issue...
You are constantly setting the LED digit - when your finger is removed - what does GetNumber return? The LED will be set to that (and it might not be a valid 'digit'?
Martin
Re: 7 seg display
Posted: Sun Mar 16, 2025 6:47 pm
by peterhalloway
I ran out of I/O so do not use the decimal point but say it is connected to B1 just to satisfy the software. I hadn't realised I did not need the common pin until I'd already layed out the board .
@martin the display gives me "8" before anything is pressed.
Thanks both
Re: 7 seg display
Posted: Sun Mar 16, 2025 7:02 pm
by mnfisher
Yes, it displays the value by Get Number each time through the loop - if no key is pressed what does it return, that is what it is trying to display...
I don't think get number waits until you press a key.
Martin
Re: 7 seg display
Posted: Sun Mar 16, 2025 7:56 pm
by chipfryer27
Hi
I think I see the problem. Nothing to do with the schematic.
If you go to Debug you can Step Into. Each click on Step Into will move one position through your chart. After the first click, Simulation Debugger appears in which you can select variables. Select the variable "keypad" which will show the value of whatever is returned from the keypad.
As you progress, you will see that with no key pressed the value of "keypad" returned is 255. You can also see that with a key pressed you get values of 0-11 (12 keys). I don't know what happens within the LED component to translate a number to segments, but I'm guessing 255 is setting them all on.
Perhaps have a decision after reading the keypad in which if the value is less than 255 then the LED is updated?
Regards