Go Down

Topic: sequential counting with buttons? (Read 726 times) previous topic - next topic

Grumpy_Mike

Quote
Just wanted to run it past you and ask if it was correct way of doing it?
Thing about programming is there are lots of ways of doing it right. What you have put looks fine.

Quote
Some the language used on this forum is out of my comfort zone.
If you find yourself not understanding what some one said then please ask them to explain the bits you understand. We are more than willing to do that. Sometimes we don't realise we are using jargon and we need reminding.

Quote
I am making an 8 step sequencer.
Ah, that would have been good to know earlier it would have put your request in context for us.

Quote
my understanding is that you know about musical instrument design.
A bit.
Here is a link to my book
https://www.apress.com/gb/book/9781484217207

Quote
and i hope you can help a little more.
Yes no problem. Is this a MIDI project?

dionnaki

No Mike this is not a midi project. I do not use midi in my system. It is a eurorack modular synth that uses -5/+5v control voltage. Otherwise, I would have bought your book ages ago. I guess this is why I am finding it so difficult to find documentation on the subject. I looked into building an arpeggiator but they were all midi based. Was seeing if it could be done without before before going down the midi route.

Grumpy_Mike

Yes it could be done but CV synths were old hat 30 years ago which is why there is little information on them.

The main problem in this digital age is the need for a split power supply, that is both positive and negative voltages. This makes the output tricky. For the output you first need a real D/A converter followed by an op amp with a times two gain and a level shift.

They use one volt per octave so the full +/-5V range would cover ten octaves which I think is more than you need. Normally there is a tuning pot to give the overall control over tuning. Without doing the sums I think a 10 bit D/A would do it unless you are into micro intervals. Using only voltages 0 to 5V would be a piece of cake but to get the extra requires a bit more work.

Assuming you only need one control output, is this right?

dionnaki

Yes I am fully aware of this. But I only need +5v for this particular prject. I will get to what you have just spoke about in good time. But at the moment I have built a prototype that works without dac. I have pots on each output to vary the amount of voltage sent to the synth. It needs to be able to sweep through full 5v. Crude but I have been using it for a few months now and it's very useful. I stripped it back to bare bones to add a sequencer section. Because at the moment it just uses a button group press or a CV input to control the which Step is playing. So no sequencer.

I just want to consentrate on getting the sequencer and the buttons to work he I want before moving on.

dionnaki

Just to add the buttons are not necessarily notes played on a keyboard. They are just stored voltages just to change stuff in the system.

Grumpy_Mike

If that is the case you could use a bank of pots and strobe them with an analogue multiplexer.

dionnaki

Can you explain the process of that please Mike in regards to my problem. Thank you.

Grumpy_Mike

#22
Jul 21, 2019, 11:32 am Last Edit: Jul 21, 2019, 11:33 am by Grumpy_Mike
Something like this only with more channels.


Each pot defines the voltage output ( note ).
Your count, in this case only two bits addresses the multiplexer and determines what voltage is outputted.

Optionally you can have a mute signal do it is only sounding when you like or to put a gap between notes.
You can get 8 channel or 16 channel multiplexers and cascade them to get as many channels as you want.

GoForSmoke

#23
Jul 21, 2019, 01:11 pm Last Edit: Jul 21, 2019, 01:17 pm by GoForSmoke
If you don't press any of the "key" buttons, should any of the leds light?

Is there any chance that the OP knows about binary bits? Didja know that you can count from 0 to 15 using just 4 fingers? If you use your thumb too, count 0 to 31 without taking your shoes off.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

meltDown

Is there any chance that the OP knows about binary bits? Didja know that you can count from 0 to 15 using just 4 fingers?
I vividly recall my maths teacher in first year high school, 1969, a grad of Reading University, teaching us binary. He sat 4 or 5 of us in chairs at the front of the class, idea being we were 0 sat, and 1 stood. If you got a tap* on the shoulder you had to toggle: sit if stood or stand if sat. If your toggle was to sit, you tapped the guy** next to you for the carry. The teacher was the counter: he had a broken leg and walked with a crutch, so the count was to hit the lsb guy on the head with the rubber thingy on the foot of the crutch.

So we all started sat as 0000. He hit the lsb guy who stood for 0001. Hit the guy again, he sat and punched the next guy who stood for 0010. Hit the lsb guy, he stood, 0011. Hit him again, he sat, punched the next guy, he sat and punched he next guy, 0100... etc.

Nobody wanted to be lsb, since that resulted in bumps on the head. Other positions resulted in punched arms. I miss those days: we were allowed to do that stuff.

* more like a punch, boys being boys

** no gals alas, boys only school.

dionnaki

Mike do you mind just explaining the context of what you mean with relation to making the buttons work the way I want. I do not understand from schematic. All I'm getting is the Arduino sending signals to choose which output on the multiplexer. How do I integrate the button functions I want? Sorry if this is dumb question.

Thanks

dionnaki

Go for smoke. If no buttons are pressed. It just steps through the LEDs sequentially when the forwards pin rising.

And I don't know about binary bits. In the way you say it. I can count binary and convert binary to hex. Etc just not very well. Need pens n paper etc.

GoForSmoke

#27
Jul 22, 2019, 05:43 am Last Edit: Jul 22, 2019, 05:44 am by GoForSmoke
Go for smoke. If no buttons are pressed. It just steps through the LEDs sequentially when the forwards pin rising.

And I don't know about binary bits. In the way you say it. I can count binary and convert binary to hex. Etc just not very well. Need pens n paper etc.
If you can count binary at all, you're along the way and could get somewhere with practice. Pens and paper are very good for impressing ideas into our heads, taking notes whether you read them later or not beats the hell out of just sitting and watching/listening. When you do think and write, you get more than think alone.

If you play with a sketch, Arduino lets you print values (variable or literal) as binary. You wouldn't be taking notes.. much worse you'd be writing code which is like notes that have to WORK. Put the code that runs once in setup(), a great place to test simple results.

byte x = 85;

Serial.println( x, BIN );  // or HEX, OCT, DEC for base 16, 8, 10.


The Mega (and all AVR chips) core processor is made of 8-bit registers, not just for doing arithmetic and accessing memory but also for getting at the pins and special chip features. Arduino lets you get at all the registers by name.

Upshot is that you can read from 8 buttons at once using 1 byte and you can write to 8 leds at once using 1 byte. You can match bits between bytes in a 1 cycle operation though reading each one seperately takes a loop.

I think that for now, this version you will use arrays and learn to walk through them using loops.

Also if you put a capacitor across each of your buttons they won't bounce and you can avoid using delays as cheap debouncing, it will make your code more responsive. How to wire those is at the address below in the section titled Hardware Debounce.

 http://www.gammon.com.au/switches

That blog also explains about switch transitions (changes in state open/closed) and why to detect those instead of simply watching the state.

In the future you may want to go with cap sense buttons you can buy or make your own, they have no mechanical movement to wear out. If your TV has touch spots for control, those are cap sense.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

GoForSmoke

I vividly recall my maths teacher in first year high school, 1969, a grad of Reading University, teaching us binary.
I started 7th grade that year but in 1964 2nd grade math in New Jersey we learned about binary along with octal and clock as alternate bases to decimal. Sorry to say that school took it no further but the lesson stuck.

Seems to me that we kids who didn't grow up with computers learned a lot of the principles that were not taught to the kids who did have them.  My main calculator was my (math geek) head but for big numbers I used a slide rule.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Grumpy_Mike

#29
Jul 22, 2019, 06:29 am Last Edit: Jul 22, 2019, 06:35 am by Grumpy_Mike
Quote
How do I integrate the button functions I want?
Those two outputs labelled count 0 and count 1 are the count that your code is producing. It is that count that decides which of the pots outputs it's voltage to the CV synth.
So at a count of zero both the count 0 line and count 1 line are both LOW.
At the count of one count 0 is HIGH and count 1 is LOW.
At the count of two count 0 is LOW and count 1 is HIGH.
At the count of three count 0 is HIGH and count 1 is LOW.

With only two lines, count 0 and count 1, you have four steps in your sequence. With three lines you can have a sequence of 8 steps, and with four line you can have a sequence of 16 steps. You need a bigger multiplexer chip of course but it is just a repeat of what is on the circuit. That is more pots, one for each step.

So your code needs to set these control lines according to the count number.

Before we get into how you do this, we need to know if this is the sort of thing you want your project to do.

Forget the button press changing the count number for the moment just concentrate on the counting / not counting.

Go Up