Maker Pro
Maker Pro

7 segment display and CMOS

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
Im looking for some guidance to start a project and would like to hear some ideas of how best to get started.

I want to build a 5V, 2 digit C/C, 7 seg. cmos counter that I can quickly scroll both up or down (1-99) possibly by using an endless digital encoder or something similar.

I guess two momentary pushbuttons would be simpler but way clunkier in this application.

This data (the number selected) would be decoded with Arduino by a Teensy 3.1 (in USB MIDI mode) and output into Midi CC data in a Digital Audio Workstation like Reaper.

If thats not possible, or above my level to read the selected data back, I would like the Arduino part of the project to at least run in parallel from the same rotary encoder/rotary switch.

I understand that they may fall out of sync in that case, so a reset mechanism would be ok.

I have the following components in various quantities, but if Im missing something important, that can be easily remedied.

CD 4013, 4093, 4017, 4029, 4511, 4049,
Max 7219,
74HC 164, 165, 595, 4051
SN74 LS47 (7447)

This is my first project with CMOS/logic gates so Im hoping to learn something from this (please keep it as simple as possible) :)

Any help would be much appreciated about how you guys might choose to go about this first part (the CMOS logic bit).

I found this schematic online here, http://roznerd.blogspot.com/2009/12/2-digit-7-segment-updown-counter.html

but am not sure if it is the right way to go.

image.jpg

thanks for looking,

vtr
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Honestly, it would be easier (simpler) to do the whole lot using the arduino.
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
Im not sure I can send MIDI over USB at the same time as 'serial data'.



image.jpg
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
so you guys can offer me nuthin then?

not even the basics on interfacing a cmos counter with a digital encoder?

ok, i guess i need to work on my social skills, then...
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
You've been given advice. That advice is to use a microcontroller.

You then made a statement that was for me meaningless, but I assumed you'd come back with a question if you had one.

In answer to the most recent question, I'd ask why, given the advice, but suggest you look up quadrature decoders. If you use one phase as the clock, and the other as the direction, you should be OK
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
Steve,

I know its possible to code 'counters' with arduino but that doesnt mean that I know how to program it.

This is where I am at so far.


image.jpg

I want to build a midi controller to control a digital audio workstation.

That is something I can currently also do with a mouse. :cool:


Maybe you are telling me that my project is just not worth the bother?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
I think we're hoping you will take some of the initiative and look for existing examples of the things you want to do. As I see it, these things are:
  • Connect a rotary encoder to an Arduino so your code can detect when it is rotated, and the direction of rotation;
  • Maintain a counter that is controlled by the rotary encoder, that wraps from 99-->0 and 0-->99;
  • Convert your counter value to two digits' worth of 7-segment display control values;
  • Drive two 7-segment LED displays from a MAX7219;
  • Identify your Arduino as a USB MIDI transmission endpoint and transmit MIDI commands.
In the real world, you are probably not the first person to want to do any of those things. Other people have probably already done them, and often, those people write up their projects so that others can benefit. (Hint: "others" in this case means you.)

Your connection to this world of information is called Google. You just need some keywords, like rotary encoder and Arduino. Did you try the search in post #6? It got lots of useful-looking hits when I tried it.

When you have done your due Google diligence, and implemented the parts of your system that have already been done and documented for your benefit, it's a good time to come to a forum, describe what you want to do, what you've done so far, and what you need help with.
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
There is a rotary encoder inside my mouse (scrollwheel), and it has two pushbuttons and a usb connector. :)

I could simply plug it in, and it would work.


But I was asking for a HARDWARE solution to the user interface i.e. the counter with LED display and a knob to twist.

I did your Google search, thanks Kris, I already have lots of code bookmarked for midi and encoders. Thats the easy bit. Even DJs can do it, apparently.


There is very little out there about driving channel displays directly with hardware counters, DJs dont have to deal with that stuff anyway.

Ive been looking for three weeks, thats maybe 150 hrs on google (musicians don't have dayjobs, remember) without finding a single solution I can adapt for use.


A midi controller has LOTS of knobs on it, mostly encoders requiring an interrupt, 2 pins, in my case.

Here is one, albeit quite a big and expensive one.

image.jpg

Otherwise you would just use a mouse. One encoder knob isn't much use on its own for this kind of thing.

If you guys are insisting I should try to load the user interface onto the Arduino too, I may not have enough room for the actual controller.

Its already taken a chunk of the memory on the Arduino board and thats just the library to light the 14 leds via the Max 7219. No actual programming of a counter or even defining the numerals yet.

If the user interface takes up a good chunk of the memory on the Arduino, Im going to have to buy another chip to dump it onto anyway.o_O


I posted a schematic using two pushbuttons (w/ CD4093, CD4029, CD4511) in post #1
http://roznerd.blogspot.com/2009/12/2-digit-7-segment-updown-counter.html

I dont know of a rotary mechanical switch that is analog I can use instead. It might work for me apart from those two pushbuttons for up and down, and also assuming I can manage to read the data.

There is even a little video of it working on the website.


Max 5440 is a digital volume controller that uses an encoder, no arduino, that seems closer to a (32 point) solution.

Max DS1804 is a 100 position non volatile digital potentiometer...


What do you think?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
What do you think?

I still think that you will get a smaller and simpler solution using a microcontroller. (And this comes from someone who really prefers to use discrete logic and discrete components rather than simply stick in a microcontroller because you can)

As Dave has said, there are easily available libraries and examples to do each part of what you want. A solution involving discrete logic will be larger, more difficult to get working, and inflexible. In addition, it will only be able to control a single channel. There's no reason not to use multiple controllers and communicate between them using something like spi (plus you may need to operate some as slaves). A full arduino (clone) module will only cost you a handful of dollars (possibly as little as $2.50).

If size, time, lack of flexibility, cost, and potential for error are no object then sure, we'll assist you with a discrete logic solution.

I'm sure there is more that you need to do, but you haven't made that clear. You seem at some points to want to do digital stuff and at other points analog.

Trust us, a microcontroller is the easiest way to get the logic stuff done, whether you need other support stuff to do some analog processing is as yet unknown.

Depending on how you're controlling those 14 LEDs, you could do it with 14 pins (I bet you are) or you could use multiplexing to control 16 LEDs with 8 pins, or charlieplexing to control 20 LEDs with 5 pins, or support chips to control an essentially unlimited number of LEDs with 3 pins. Some of these support chips are built into the LEDs, so you can use some LED modules that can be strung together allowing you to set each LED to not only be on or off, but any one of thousands of colours and intensities.

*if* your rotary encoders have huge numbers of pulses per rotation (hundreds) as opposed to 20 or so for ones normally used as rotary controls, then arduino interrupt latency may be an issue causing lost input pulses, but you have said nothing about this, and I expect you're not planning to need to track absolute angles using the encoder, just pulses clockwise or anticlockwise. Again, depending on your solution, one arduino might be able to handle several rotary encoders and several counters without requiring much in the way of external support.
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
Thanks, Steve.

I was wondering how I was going to make a single 24 pulse encoder drive both Arduino/midi and a logic circuit for the display simultaneously.

I will probably try experiments with both Arduino and IC's just to see how it works out for me. Im not worried if its a dead end, I already have a box full of ICs that could be useful.

The only way for me to learn any of this stuff is to actually try it.

The pic of the breadboard in post #7 has a Max7219 driving 2 digits using 3 pins of a Teensy 3.1 microcontroller using the LedControl library.
https://www.pjrc.com/teensy/td_libs_LedControl.html

I only need to track the counter in Arduino either up or down, so detecting a rising or falling edge.

Basically Im sending a Control Change message via Midi (the Teensy can do this) to select the channel displayed on the counter to the DAW.

The other encoders will have assigned functions for the parameters of that channel.

Doesnt seem too difficult if i can solve the counters LED display.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
One potentially important issue is that if you have a solution where the counters are separated from the midi controller, the count displayed may not match the information being sent to the midi device. I have no idea if this is actually important in your device that they remain in sync.

It would seem reasonable that you would be talking to many of these counters, but it would all be funneled through a single midi interface. As such, a major consideration is how you handle these communications.

It would seem sensible to design this in a way that can support just a single, or perhaps a very small number of these counters, but be easily expanded to support more.

If you want to explore discrete logic, then you may be able to use an up/down counter (you need 7 bits for 0 to 99 unless you have a bcd counter which would require 8 bits (practically speaking both would be 8 bit). Following this you may need a bcd to decimal decoder, and then a 7 segment decoder driver. The rotary encoder can be used with one channel providing the clock, and the other the direction. The major issue will be finding a suitable set of chips to handle the up/down counting that can also reasonably directly be decoded and displayed. Along with this would be logic to output the information you require. It might be easier to start with a single digit (0 to 9) first, before progressing to two digits.

Rereading your post, I'm not exactly sure whether you're using midi externally only, or also internally as a means of connecting the channels.
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
Ah well, now you mention it, synchronicity might be a problem, but I would be ok with a 'reset' mechanism of sorts.

To try to explain this project simply...

All channels in the DAW (its essentially a multitrack recording and mixing studio application that can accept analog or digital commands via Midi Control Changes) are essentially identical from channel 1-99.

So, to change a parameter on an effect, I need to select the channel (of the instrument I want to work on) then adjust the appropriate knob assigned to that parameter.

If I move to another instrument, (I have to change the channel first) then that same parameter will also be assigned to that same particular knob, too.

The LED display identifies/selects the channel I want to work on. The encoders are assigned to those specific parameters on each and every channel.

If I want another effect, on that same channel, it will have its own set of knobs to control its parameters.

So two midi controllers may work (independently) on the same selected channel, adjusting their own specific parameters on different effects, and still display the same channel number (1-99) simultaneously...


All midi control changes take place in Arduino, and the microcontroller Im using for Arduino can also be recognized as 'MIDI over USB' hardware (which is pretty impressive) so no external device is necessary.

If you mean, will I also be using a mouse to select channels or effects? well .... yes, probably.

I hope thats clearer than mud...



I guess that also means that all the midi control is internal (inside the micro controller).

As for connecting multiple channels / midi controllers / counters... well I hadn't dared go there yet, but yes, that was eventually the plan, to possibly link them...
if its not too complicated.


Personally, I might just stop at 32 channels, but thats essentially the same as 99 as far as 2 digit counters go, so Im happy with 99 as a maximum.

Just to make it work, less channels/a single digit would be acceptable as a starting point (for simplicity), but practically it would be nowhere near enough unless you only mix jazz or classical records :)
 
Last edited:

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
So I built this circuit (see pics below) just to see if it would work...

but I didnt know how to wire the LED display to the CD 4511's.

I only have 10 pins on the 2 digit led display, and two of them are common cathode pins currently wired to GND.

The counter and reset switch doesnt work,

Can anybody shed any light on this? How would you wire my LEDs into this circuit?image.jpg


image.jpg View attachment 14409
 
Last edited:

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
image.jpg oops, forgot to put the 5v to the IC's...

stuff changes when i press the buttons but it doesnt count :(

View attachment 14415
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Your 2 digit display is designed for multiplexing. Without adding a reasonable amount of logic, you're not going to be able to easily drive these from just 4511s.

You would be better off with 2 single digit displays.

I will have look to see if there's a simple way, but don't hold your breath.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Google "CD4511 multiplex" for a stack of examples.
 

vtr

Jul 27, 2014
10
Joined
Jul 27, 2014
Messages
10
I pulled the CD4511 from its socket on the left, and just worked on the right hand one. Its nearly working right, just a couple of little anomalies (w/two segments) to iron out, hopefully tomorrow.

Maybe I also need a larger value cap to fix the debounce? It seems to skip a number or two occasionally.

The same digit still shows up both sides though. Good to know why, thanks steve.

I have mux's, will look it up and let you know.

Otherwise I can just fit another 2 digit display alongside just to get it to work for now and disconnect one cathode on each.

Then I can have a go at the Arduino version of the same thing. Im a sucker for punishment. o_O
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Otherwise I can just fit another 2 digit display alongside just to get it to work for now and disconnect one cathode on each.

Yes, that is a solution to being able to see both digits. Sorry for not mentioning it.
 
Top