MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Pages: 1

Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


MAME's Output: 7-Seg to Dec/Bin?
#317269 - 11/12/13 12:50 AM


I'm having another go with the output system again but this time I'm trying to interface MAME's output (through MAME Hooker) to an Arduino using a RS232 link. Problem is I'm trying to get the 7-Segment displays from the NEO-GEO to function but am getting stumped on how to convert the values. As I noted last time the output system outputs what pins on the 7-seg display would be high so you could directly drive the display from that, however I cannot using an RS232 link but I don't know how to convert this value back to decimal or binary. For example I have the following list of the output numbers:

Code:

 1 = 6
2 = 91
3 = 15
4 = 102
5 = 109
6 = 124
7 = 7
8 = 127
9 = 111



To me there doesn't seem to be much of a pattern in order to make a single converstion.

Any ideas on if/how to convert them?



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



Matty_
Part-time troll
Reged: 01/25/08
Posts: 730
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317270 - 11/12/13 01:23 AM


> Any ideas on if/how to convert them?

Make your Arduino drive the 7-segment displays directly from each of the bits so you don't have to convert?

Or if you really can't do that, convert using a lookup table, or a big, nasty if/else/if tree?



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Matty_]
#317271 - 11/12/13 01:48 AM


> > Any ideas on if/how to convert them?
>
> Make your Arduino drive the 7-segment displays directly from each of the bits so you
> don't have to convert?

I'm going to be using multiplexing so this won't work for me. I did consider such but that's just too easy

> Or if you really can't do that, convert using a lookup table, or a big, nasty
> if/else/if tree?

I considered both of these two, however I feel the IF commands would be repetitive and inefficient (not that it would really matter) but would be possible. Also the look up table i'm not sure how to implement in code.

Thanks



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



Matty_
Part-time troll
Reged: 01/25/08
Posts: 730
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317276 - 11/12/13 04:06 AM


> > Make your Arduino drive the 7-segment displays directly from each of the bits so you
> > don't have to convert?
>
> I'm going to be using multiplexing so this won't work for me.

There's nothing to stop you doing that with multiplexing.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317304 - 11/12/13 08:52 PM


As Matty hinted, each bit drives one of the segments. If you turn the numbers into hex or binary and compare with a drawing of a 7-segment display that becomes much more clear.

If you want to identify the number, you pretty much have to just compare against an array of the possible values for the 10 possible digits that can be displayed.



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: R. Belmont]
#317305 - 11/12/13 09:19 PM


> As Matty hinted, each bit drives one of the segments. If you turn the numbers into
> hex or binary and compare with a drawing of a 7-segment display that becomes much
> more clear.
>
> If you want to identify the number, you pretty much have to just compare against an
> array of the possible values for the 10 possible digits that can be displayed.

I know that the bits are the actual segments, I just wondered if there was an easier way of converting the bits back into a decimal number, but like you both say a lookup table would pretty much be the only way.

Thanks



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



TafoidAdministrator
I keep on testing.. testing.. testing... into the future!
Reged: 04/19/06
Posts: 3135
Loc: USA
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317306 - 11/12/13 10:13 PM


> > As Matty hinted, each bit drives one of the segments. If you turn the numbers into
> > hex or binary and compare with a drawing of a 7-segment display that becomes much
> > more clear.
> >
> > If you want to identify the number, you pretty much have to just compare against an
> > array of the possible values for the 10 possible digits that can be displayed.
>
> I know that the bits are the actual segments, I just wondered if there was an easier
> way of converting the bits back into a decimal number, but like you both say a lookup
> table would pretty much be the only way.
>
> Thanks

1) Use your calculator in Windows, Programmer Mode (alt-3).
2) Assure you have "Dec" radio button selected.
3) Type in your integer for the appropriate number on LCD
4) Select "Bin" radio button, you'll get 0 and 1 output.
5) Match that output to the segments
6) Repeat at 2 until done

It's best to start with numbers which have less segments used (start with 1 (2 segs), 7 (3 segs). The rest is a process of elimination.

This picture might help too



ASI
MAME Fan
Reged: 02/23/10
Posts: 30
Loc: UK
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317309 - 11/12/13 11:26 PM


Ok based on your info this maps to ...

bits
7 6 5 4 3 2 1 0

bit 7 = 0
bit 6 = Center Line
bit 5 = Top Left
bit 4 = Bottom Left
Bit 3 = Bottom Line
Bit 2 = Bottom Right
Bit 1 = Top Right
Bit 0 = Top Line

Hope this helps


That means that 0 would be 63

Edited by ASI (11/12/13 11:28 PM)



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: ASI]
#317326 - 11/13/13 01:55 PM


> Ok based on your info this maps to ...
>
> bits
> 7 6 5 4 3 2 1 0
>
> bit 7 = 0
> bit 6 = Center Line
> bit 5 = Top Left
> bit 4 = Bottom Left
> Bit 3 = Bottom Line
> Bit 2 = Bottom Right
> Bit 1 = Top Right
> Bit 0 = Top Line
>
> Hope this helps
>
>
> That means that 0 would be 63

Thanks for the info ASI and Tafoid. I know that these are the actual bits for controlling the 7Seg.

I should elaborate. Whilst MAME gives me the binary for the segment's lights, I wanted to convert that into an integer for my program to convert and send the BCD data (through a 74595 shift SIPO register) to a 4511 chip to control the 7Segs.

MAME > MAME Hooker > RS232 > Arduino > BCD > 74595 > 4511 > 7Seg.

This is why I've been wondering if at all I can convert it but it seems easier to just ditch the 4511 and just run the displays from the 74595 and select which display using a 4017 and transistor arrangement.


Thanks



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



italieAdministrator
MAME owes italie many thank yous, hah
Reged: 09/20/03
Posts: 15246
Loc: BoomTown
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317328 - 11/13/13 03:20 PM


> > Ok based on your info this maps to ...
> >
> > bits
> > 7 6 5 4 3 2 1 0
> >
> > bit 7 = 0
> > bit 6 = Center Line
> > bit 5 = Top Left
> > bit 4 = Bottom Left
> > Bit 3 = Bottom Line
> > Bit 2 = Bottom Right
> > Bit 1 = Top Right
> > Bit 0 = Top Line
> >
> > Hope this helps
> >
> >
> > That means that 0 would be 63
>
> Thanks for the info ASI and Tafoid. I know that these are the actual bits for
> controlling the 7Seg.
>
> I should elaborate. Whilst MAME gives me the binary for the segment's lights, I
> wanted to convert that into an integer for my program to convert and send the BCD
> data (through a 74595 shift SIPO register) to a 4511 chip to control the 7Segs.
>
> MAME > MAME Hooker > RS232 > Arduino > BCD > 74595 > 4511 > 7Seg.
>
> This is why I've been wondering if at all I can convert it but it seems easier to
> just ditch the 4511 and just run the displays from the 74595 and select which display
> using a 4017 and transistor arrangement.
>
>
> Thanks

I was going to help, but that seems overly complicated...Why is the Arduino in there again?



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317337 - 11/13/13 06:16 PM


> MAME > MAME Hooker > RS232 > Arduino > BCD > 74595 > 4511 > 7Seg.

WTF?

Just connect the 7 segments to 7 GPIOs on the Arduino and then you don't need to decode anything.



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: italie]
#317358 - 11/14/13 02:16 PM


> > > Ok based on your info this maps to ...
> > >
> > > bits
> > > 7 6 5 4 3 2 1 0
> > >
> > > bit 7 = 0
> > > bit 6 = Center Line
> > > bit 5 = Top Left
> > > bit 4 = Bottom Left
> > > Bit 3 = Bottom Line
> > > Bit 2 = Bottom Right
> > > Bit 1 = Top Right
> > > Bit 0 = Top Line
> > >
> > > Hope this helps
> > >
> > >
> > > That means that 0 would be 63
> >
> > Thanks for the info ASI and Tafoid. I know that these are the actual bits for
> > controlling the 7Seg.
> >
> > I should elaborate. Whilst MAME gives me the binary for the segment's lights, I
> > wanted to convert that into an integer for my program to convert and send the BCD
> > data (through a 74595 shift SIPO register) to a 4511 chip to control the 7Segs.
> >
> > MAME > MAME Hooker > RS232 > Arduino > BCD > 74595 > 4511 > 7Seg.
> >
> > This is why I've been wondering if at all I can convert it but it seems easier to
> > just ditch the 4511 and just run the displays from the 74595 and select which
> display
> > using a 4017 and transistor arrangement.
> >
> >
> > Thanks
>
> I was going to help, but that seems overly complicated...Why is the Arduino in there
> again?

Because I'm trying to learn how to use and control over devices with it. The whole reason for the 74595 was to expand the ability for I/O.



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: R. Belmont]
#317359 - 11/14/13 02:18 PM


> > MAME > MAME Hooker > RS232 > Arduino > BCD > 74595 > 4511 > 7Seg.
>
> WTF?
>
> Just connect the 7 segments to 7 GPIOs on the Arduino and then you don't need to
> decode anything.

I don't need to decode it if I don't use the 4511, I realize now I can just send the direct values to the 74595 and it'll work properly. This way I avoid converting to BCD and needing the 4511 but I thought it'd be the proper way to use 7Segs.

And using the 74595 to expand my I/O capabilities and because then I can send the values received in from MAME straight to the chip, no conversion needed.

Edited by Naoki (11/14/13 02:22 PM)



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317371 - 11/14/13 07:39 PM


> And using the 74595 to expand my I/O capabilities and because then I can send the
> values received in from MAME straight to the chip, no conversion needed.

If you drive the 7-segment directly from Ardino GPIO you don't need to convert the values. That's the entire reason I said to do that.



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: R. Belmont]
#317377 - 11/14/13 10:22 PM


> > And using the 74595 to expand my I/O capabilities and because then I can send the
> > values received in from MAME straight to the chip, no conversion needed.
>
> If you drive the 7-segment directly from Ardino GPIO you don't need to convert the
> values. That's the entire reason I said to do that.

He won't have to convert the values if he uses the 74595 either. You missed that he wants to do it as an exercise in driving an external shift register. It makes a bit more sense now.



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Vas Crabb]
#317379 - 11/14/13 11:17 PM


> > > And using the 74595 to expand my I/O capabilities and because then I can send the
> > > values received in from MAME straight to the chip, no conversion needed.
> >
> > If you drive the 7-segment directly from Ardino GPIO you don't need to convert the
> > values. That's the entire reason I said to do that.
>
> He won't have to convert the values if he uses the 74595 either. You missed that he
> wants to do it as an exercise in driving an external shift register. It makes a bit
> more sense now.

Yes, like I said I can use the output straight from mame and send it to the shift register as the decimal output gets converted to the right binary output just due to the nature of the devices.



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



italieAdministrator
MAME owes italie many thank yous, hah
Reged: 09/20/03
Posts: 15246
Loc: BoomTown
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317394 - 11/15/13 04:51 AM


> > > > And using the 74595 to expand my I/O capabilities and because then I can send
> the
> > > > values received in from MAME straight to the chip, no conversion needed.
> > >
> > > If you drive the 7-segment directly from Ardino GPIO you don't need to convert
> the
> > > values. That's the entire reason I said to do that.
> >
> > He won't have to convert the values if he uses the 74595 either. You missed that he
> > wants to do it as an exercise in driving an external shift register. It makes a bit
> > more sense now.
>
> Yes, like I said I can use the output straight from mame and send it to the shift
> register as the decimal output gets converted to the right binary output just due to
> the nature of the devices.




Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: italie]
#317422 - 11/15/13 03:27 PM


> > > > > And using the 74595 to expand my I/O capabilities and because then I can send
> > the
> > > > > values received in from MAME straight to the chip, no conversion needed.
> > > >
> > > > If you drive the 7-segment directly from Ardino GPIO you don't need to convert
> > the
> > > > values. That's the entire reason I said to do that.
> > >
> > > He won't have to convert the values if he uses the 74595 either. You missed that
> he
> > > wants to do it as an exercise in driving an external shift register. It makes a
> bit
> > > more sense now.
> >
> > Yes, like I said I can use the output straight from mame and send it to the shift
> > register as the decimal output gets converted to the right binary output just due
> to
> > the nature of the devices.

Ya, at the risk of seeming more mad I'll stop talking .
Thanks guys



----
On a quest for Digital 573 and Dancing Stage EuroMix 2

By gods I've found it!



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Vas Crabb]
#317428 - 11/15/13 05:52 PM


> He won't have to convert the values if he uses the 74595 either. You missed that he
> wants to do it as an exercise in driving an external shift register. It makes a bit
> more sense now.

That's fine, but he needs to stop claiming he's going all perpetual motion machine to avoid having to convert the values then, because no conversion is necessary to drive the display right off the GPIOs.



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: R. Belmont]
#317431 - 11/15/13 07:58 PM


> > He won't have to convert the values if he uses the 74595 either. You missed that he
> > wants to do it as an exercise in driving an external shift register. It makes a bit
> > more sense now.
>
> That's fine, but he needs to stop claiming he's going all perpetual motion machine to
> avoid having to convert the values then, because no conversion is necessary to drive
> the display right off the GPIOs.

I never said conversion was necessary for running of the GPIO but was necessary for the 4511 7-Segment driver which requires 4-bit BCD input and just due to the way the system was setup I wanted/needed to convert it to an integer value.

Edited by Naoki (11/15/13 08:19 PM)



Naoki
Reged: 11/10/09
Posts: 1998
Loc: United Kingdom
Send PM


Re: MAME's Output: 7-Seg to Dec/Bin? new [Re: Naoki]
#317432 - 11/15/13 08:16 PM


Ok, whilst I got my answer, for clarification, this is why I asked in the first place.

So, the idea is the Arduino would receive the data from MAME Hooker saying what 7-segs would need to display and where and the Arduino would convert MAME's output into a format I could work with (integer values) and then also know which displays needed what number.

From there it would be sent to the 74595 which would have driven a 4511 BCD to 7-Segment to save on I/O, with the latter 4-bits to select which display (so I only needed 3 pins of data for 4 7seg displays).

The 4511 would receive the data from the Arduino to know what needed to displayed and would set such outputs whilst NPN transistors would select which display to have the 4511's output shown on.

The reason I wanted to use the 4511 or even just the 74595 is to save the I/O pins for other things like lamp outputs and so that I could make an easy to expand display interface. As said I was also learning about how to use shift registers. And whilst I said I wanted to make a "universal system" yet it'd convert mame's outputs on-board, the plan was to send a "system" ID from MAME Hooker to say it needed to convert such values.

Also, whilst I could drive the 7-Seg directly from the Arduino or the 74595, I was conserving I/O and making a sort of multiplexed system.

Edited by Naoki (11/15/13 08:17 PM)


Pages: 1

MAMEWorld >> EmuChat
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 516 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2634