Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing incremental rotary encoder with AVR mcu to controll DAC output.

Status
Not open for further replies.

David_

Advanced Member level 2
Joined
Dec 6, 2013
Messages
573
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,308
Location
Sweden
Activity points
12,220
Hello.

I have been trying to understand and to implement some circuit using incremental rotary encoders interfaced with a microcontroller(by the way, does one interface a circuit with another circuit or does one interface a circuit to another circuit?), I need two encoders that are in the end going to adjust voltages and current settings of a power supply but I have not found any implementation that suited me. I have read all i can find on the internet about the subject but I am really just in the beginning of learning programming and it really is over my head, and I don't want to implement copied working code that i do not understand. The uC I'm using ATmega 328 have only two external interrupts, I could change to ATmega2560 and get lots of external interrupts but it does cost a lot more and its a hazel to etch and solder those packages. However I have found a solution that I think might be just right but I am a little lost,
LS7183 and LS7184: **broken link removed**
are two quadrature clock converters, both are exactly the same apart from the output structure. The datasheet suggest a circuit to drive a 4-bit binary up/down counter which i first thought might me something, but I can't figure out how the 40193 works but I don't think that is what I'm looking for anyway. **broken link removed**

LS7183 have two different low-going pulse outputs which is only active one at a time, which one depends on the rotational direction of the encoder. So I guess I could use one external interrupt somehow to indicate that the uC need to pay some attention to two digital inputs in order to count clock cycles, one input for up and one for down.
or
LS7184 have a clock output and a count direction indication output. When A input leads the B input, the UP/DN output goes high indicating that the count direction is UP. When A input lags the B input, UP/DN output goes low, indicating that the count direction is DOWN. So in that case i would alert the uC with a external interrupt(one interrupt for both encoders) and then count the clock pulses coming from LS7184 meanwhile check if the UP/DN signal is low or high in order to increase a value or decrease a value.
Is this a viable approach?

LS7183.png
The resistor is used to adjust the pulse width and the jumper next to the supply voltage is used to select clock rate multiple, low= x1 high= x2 floating= x4.

As for the DAC, its a 16-bit voltage output DAC communicating with I2C. It needs to receive a 16-bit word in order to set the output, first MSB byte then LSB byte(after adress and controll byte) there is no library for the part DAC8574 and I thinking about how to best implement the setting and adjusting the 16-bit word. I will have a keypad to be able to type desired output voltage/current limit as well as two encoders, its a dual rail power supply so i thought I would use one encoder for positive voltage/current limit and the other for the negative rail voltage/current limit.
Is it a good idea to always use a 16-bit word?
So when a encoder is rotated, depending on the direction the 16-bit word is decreased or increased, or if value is typed in Ex 15V, then I convert that 15V decimal number into a 16-bit proportional representation, voltage= 0-30V 16-bit number= 0-65536?

I have some help as a helpful man have designed a similar device and he does share all of it,
https://www.ianjohnston.com/index.p...le&id=92:powersupply&catid=3:hobbies&Itemid=8

I use similar ICs but I am designing my own supply very similar to Ians first version that he scraped, I'm sure he's design are superior to my own. But again it is my own and I don't understand all of his, but from he's design I got knowledge about things like NewMAP routine as opposed to Arduino MAP version which I'm told fails above 32767.

I don't know how he is using it but I imaging that I can remap 0-30V to 0-65536, right?

If I have a 16-bit word, or two bytes(MSB & LSB) that are going to be used to send to the DAC but should continuously be available for different parts of the code in order to adjust and change it, I have started reading about all different classes or what it is called, int double etc. Do I have to make the 16bit word a volatile variable or something like that?

All kind of input is most welcome.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top