Hi all, I'm looking for suggestions/help on a project I have in mind.
In short:
One encoder controlling 3 pmw outputs, if button A has been pressed the encoder changes pmw output A1' if button B has been pressed the encoder change pmw output B1 and so on. I will use the pmw outputs to control digipots. The last state of the pmw outputs for each channel should be stored in eeprom preferably. So when switching channels the last pmw value will be present until encoder is turned again for the that channel.
It will actually be 5 encoders each controlling 3 pmw outputs based on which channel (A,B or C) is active. I'll probably use several boards for this
I have already made an arduino pro mini based 5 channel switcher, switching between 3 channels, and turn on/off 2 more outputs independently, but my programming knowledge is still limited. I'm not looking for a full code but if somebody can give me some hints or examples it would been very helpful.
You will have 5 pwm signals. (one per "channel")
Each signal will be one of three possible for that channel.
The default signal selection for each channel will be held in eeprom so that upon a reset, the correct signal will be selected for each channel.
This is all easy enough to do with just one arduino. (assuming that the frequency of modulation is within reasonable limits).
Now where I'm struggling is how you update the current signal selection for any channel. You talk of "encoders" but don't give details of exactly what you mean by that.
Do you know what kind of output these rotary encoders have. Better still, do you have a link a datasheet for them? Or are you going to be building them yourself?
Also, Do you have some examples of the frequencies you'll be wanting to send to your digipots.
Here's an example: https://www.sparkfun.com/datasheets/Components/TW-700198.pdf
The resolution of the encoder will most likely be 12 or 24 steps per rotation.
The frequency of the pmw I'm not sure on yet, I guess the default should do fine...
Digipots should step through 64 levels of resistance.
Ps. I don't know if i2c instead of pmw would be a better choice.
Is it your intention to use the encoders to detect the speed (and direction, perhaps) of rotation of something (what?) and then produce a PWM (Pulse Width Modulated) signal proportional to the detected speed?
If your somethings are rotating quickly it may be difficult to manage 5 encoders.
Allocating the outputs in response to button presses should be straightforward.
I cannot see what PWM has to do with digital pots. The only input a digital pot needs is a number - in effect the same number that would be used to set the PWM duty cycle.
What are the digital pots for?
As with many other questions it would be great help if you tell us WHAT you want to do to supplement your proposals for HOW you think it should be done. There may be another way.
I've given this some thought and I think I've made it more difficult than needed. Thanks for the questions.
I want a rotary encoder to control 1 output, to give out an analog voltage between 0-5 volts, in say 64 steps. If you turn the encoder right the voltage will go up, if you turn left the voltage will go down.
If button A has been pressed and you turn the encoder to give this output a voltage of 4 volts, then if you press button B and turn the encoder so the output is 3 volts, when you press button A again the output will be 4 volts again, hence it has remembered the last output state (voltage) for this button. Then If you press button B again the output will be 3 volts. It will stay like this until the encoder is turned again. And if you turn off and on again it should remember the last states until the rotary encoder is turned. I hope you understand my bad explanation. And that it doesn't confuse you.
I will use this analog output voltage to control 3 circuits that will be chosen depending on which button has been pressed.
I will do some more research, to see if I can find a ref to what I want to achieve. I was under the impression that I would maybe need a digipot to get the analog voltage, but maybe there is an easier way?
Thanks
So to condense this all down to simple terms. You are going to have 5 analog output voltages. You want to be able to set each one independently using a rotary encoder. This is simple stuff. If you have some kind of display to provide feedback, you wouldn't even need the separate buttons. You could just use one button to index through them until the appropriate item is displayed and then twiddle your encoder to adjust its value.
The problem with an analogue output controlling an LED is that for a lot of the output voltage range the LED will simply not be lit. Then over a very short range the LED will get bright very rapidly, then the rest of the range the brightness will not change much.
Almost correct:)
5 analog output voltages, 5 encoders, each of the outputs can have 3 saved states based on which button (a,b,c) has been pressed and how you dialed in the encoders when you where in that state. I don't want to use a lcd etc, I want to use 3 LEDs to see which button (a,b,c) is active, or more correctly: has lastly been pressed. To monitor the outputs I want to use rotary encoder led rings on each encoder to see where I am on a 0-10 scale. Think volume pot for instance.
So the result of the output or what will eventually be the output is a fully analog voltage, not PWM. At least I spelled that right:) would a digipot be the way to achieve this or do you have another suggestion? I'm sure this is simple stuff to the most of you, but please bare with me, I'm on a slow learning curve here...
Korhipt:
I want a rotary encoder to control 1 output, to give out an analog voltage between 0-5 volts, in say 64 steps. If you turn the encoder right the voltage will go up, if you turn left the voltage will go down.
That sounds like gross overkill. Why not just use a potentiometer?
Because when I switch between button (channels) A,B,C i will get the same value On the output...
I want the possibility to have different voltages on the same output, depending on which button has been selected. In this case, so I can control the volume on 3 separate audio channels independently, with the same controller(rotary encoder). So when I switch between channels they can have different volume, and the volume for each channel will be remembered until I choose to adjust it again.
And before you ask, the signal levels in play will be to high to use a digipot or similar, they only work up to 30-40v range. I will use this small voltage (0-5v)to control a circuit that attenuate audio signal levels in the 100-250v range.
This way I can have gain,tone(treble,middle and bass) and volume adjustment with only five controls for all 3 channels, instead of 15, five for each channel. Saves space on the control panel, right?.
And before you ask, the signal levels in play will be to high to use a digipot or similar, they only work up to 30-40v range. I will use this small voltage (0-5v)to control a circuit that attenuate audio signal levels in the 100-250v range.
I think you're confusing the purpose of the digital pot. The digital pot would be used to create the 0-5V (low level) control signal for your attenuation circuit. An Arduino could easily handle the serial communications to multiple digital pots and allow for stored settings and various control functions.
dlloyd:
Yes, I early in my post referred to pwm-digipot, but at that time i did not mention that I would use the digipot to create this low level control voltage, as I did not think it was significant.
This time I just stated that a digipot would not be up for the attenuation job itself.
I could maybe use just a rc filter on the pwm output, to make this control voltage. The reaction time is not a concern, only the ripple, but that could be smoothed with more filtering. Then I would not need digipots, less parts is better.
In a snippet from my channel switch sketch (pseudo), I have:
Loop
}
If button A been pressed
Case =1
EEPROM.write(adress,case)
Else
If button B been pressed
Case=2
EEPROM.write(adress,case)
Else
If button C been pressed
Case= 3
EEPROM.write (adress,case)
Switch (case)
Case 1:
Case 2:
Case 3:
Break
Where should I put the program handling the counting and pwm? After some study I should be able to write a standalone code that can count the pwm up/down (0-255) with the encoder, but at this time I'm not sure how I should merge it with this code. In the if statements, or in the cases or other?? I will also need to save the last pwm output for each channel. Maybe do eeprom write for this also. Ideas and corrections are welcomed. Thanks.
Wow KenF, a big thanks so far. I will play with this and try to integrate it with my other code.
If a couple of rc filters won't be good enough ripple wise, then a digipot will be the next solution.
i'll post if i can make a working circuit. Though it will take some time since I will be constant traveling for the next month
Thank you all for asking Q and bearing with me on this.