go_away

Author Topic: Pi Bot with microcontroller + Quadrature Encoders + Clock Converter(s)  (Read 2303 times)

0 Members and 1 Guest are viewing this topic.

Offline RussellPiBotTopic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 1
Challenge:
To connect encoder outputs that will provide error feedback to a microcontroller of a four (4) wheeled Bot.

Background
I am in the process of laying out a circuit connection board to support battery power distribution to motor drivers whose outputs will be returned to the connections board to be wired to the six (6) wire connectors from the motor encoders; then the A and B encoder outputs will be distributed to a Pi Hat (custom Arduino Uno) fitted with LS7184 clock converters whose outputs will be wired to the ATmega328 microprocessor.  Wow that is a mouthful!

The Bot motors will be powered by two (2) 6V 3300mAh battery packs in parallel and fused at the connections board.

The Pi will communicate with the Arduino using I2C via a MCP23017, and the Arduino will control the motor speed and direction using PWM.

Summary of Components and Processes in Play
>Four 75:1 geared 6V DC motors with 6A stall current and 48 CPR Hall Effect encoders

>Four (4) Pololu motor drivers #1451which are matched to the DC motors – to save microcontroller I/O lines the PWM input pin of the driver boards will be held “high” by connecting them directly to the 5V VDD supply to the driver board.
 
>LS7184 clock convert(s) - at this point I am not sure how many LS7184 will be needed or if this is the best way to interface the encoder signals with the microcontroller.

>Custom Arduino Uno Pi Hat (bare bones Arduino) using Atmega328 microcontroller with 16KHz crystal.

At this point I am not concerned with code, I will deal with that big challenge down the road.  My focus at the moment is on completing the Pi-Bot's circuits, modules, (power supplies, GPIO interfaces for the Pi and Arduino, etc.), circuit board, motor, and battery locations (bottom of 1st deck, top of 1st deck or 2nd deck of the chassis) and how best to connect everything to facilitate charging batteries, modifying and servicing the Bot.

That said, I need advice and guidance to help me complete a connection board wiring plan with regard to how to connect the A and B outputs from the encoders to the clock converters and then the LS7184 to the ATmega328.  Of particular interest are pin numbers that should be used to connected the LS7184 to the microprocessor any any pull-up, pull-down or protection circuits that should be used.

The above Bot concept sounds good on paper, at least to me, a relatively uninformed robot newbie!

Therefore, comments with regard to the above Bot operational concept, in addition to the needed wiring advice, would be greatly valued.

Cheers,

Offline mklrobo

  • Supreme Robot
  • *****
  • Posts: 547
  • Helpful? 14
  • From Dream to Design at the speed of Imagination!
Re: Pi Bot with microcontroller + Quadrature Encoders + Clock Converter(s)
« Reply #1 on: February 25, 2015, 05:01:00 PM »
 8) Cool!  8)
I have just acquired a Ardunio bare bones MCU board, and plan to
start programming soon. I saw some code on Youtube, and it looked like
a C program, with javascript.(?) Very similar to programming a beagle bone black.
What I would do is set up a test fixture, to make sure everything is working, then
devise the housing for the robot.(unless you already have a plan)
I was wondering, How many instructions per second does the ATmega328 process?
The ATmega328 would be great for the dedicated processes, and coupled with a
beaglebone or Raspberry PI, is a powerfull combination. For input/ooutput protection,
I use optocouplers to protect my microcontroller. More circuitry is required, but you get
attached to your robot after spending alot of time.(do not want to see it go, POOF!)
Sooner or later, I am going to make a robot to cook my eggs and bacon, like on
the movie, Chitty, Chitty, Bang Bang!
Keep Me posted.......... ;D ;D ;D ;D

Offline bdeuell

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 15
did you read the datasheets for theses devices?

Quote
to save microcontroller I/O lines the PWM input pin of the driver boards will be held “high” by connecting them directly to the 5V VDD supply to the driver board.
It sounds like you plan to hard wire the motors to full speed. Is this correct? if so what is the intended use of the encoder feedback?

I did not see any part numbers or pinouts for the motors/encoders in you post so it is hard to provide guidance on how to connect them.

LS7184 to Atmega 328
pin 7 (up/dn) --> Atmega 328 (digital input)
pin 8 (CLK) --> Atmega 328 (digital input, i recommend using a pin that is interrupt enabled)

you will need one LS7184 chip for each encoder. these chips would work fine for interfacing the encoders but be aware that they do not count pulses, your microcontroller will have to count the clock pulses every time one is received which consumes processing time. you must be careful to ensure that your micro is not caught up in other process such as figuring out where to drive and misses the encoder clock signals, this is why i recommended an interrupt pin.



Offline Billy

  • Robot Overlord
  • ****
  • Posts: 132
  • Helpful? 2
It sounds like you plan to hard wire the motors to full speed. Is this correct? if so what is the intended use of the encoder feedback?

I know that in some instances the control can be done holding the PWM input high and toggling the direction line. When the duty cycle is 50% the motor has virtually no current. You vary the duty cycle on the direction pin away from 50% to run current through it. It means you can go both forward and backwards controlling only one pin. The normal way requires both direction and PWM.
Of course the toggling has to be fast enough that the current through the motor is kept low due to the inductance. Think kHz above hearing. 
I've never controlled a motor that way, but it should work.

The real issue in pulling that line high directly will be that when the controller is being reset, or programmed, or crashes, the motors will run away. It's a really high price to pay to save one pin.

Offline bdeuell

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 15
@Billy - thanks for that info, I had not heard of this control method before. Are you aware of any advantages or applications for this motor control technique?

Offline Billy

  • Robot Overlord
  • ****
  • Posts: 132
  • Helpful? 2
@Billy - thanks for that info, I had not heard of this control method before. Are you aware of any advantages or applications for this motor control technique?

I've never heard of any real advantage in practice, but I have never researched it. They call it "Locked Anti-Phase PWM Control". Let me know if find out anything interesting.

 


Get Your Ad Here