• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Brainstorming a 6 motor h bridge w/pwm and angular feed-back

Status
Not open for further replies.

urthlight

New Member
I am building a 6 degree of freedom robot arm. The axes are driven by dc gear motors. I have 6x 6-transistor h-bridges one for each axis motor, these are 2 input devices
00=coast
01=fwd
10=rev
11=brake
I have 100k linear variable resistors on each axis and physical limit switches.

I would like to use pic(s) for the rest of my logic. Each motor needs to have its own profile in the controller due to different rpm ranges. The 6th motor could be a R/C servo for the gripper.

The list of functions would include:
acceleration/decceleration
station keeping (the elbow lowers when the shoulder is rising and needs to be compensated for)
home/park (find home safely on power up / alternate safe position)
hi speed / low speed

I have a variety of pics and the easy pic 4 with basic and c.

So, you see I have many questions.
The obvious ones are:
Which language? I prefer basic my c is rusty
Which pics? so many choices.
how many pics? I have 5x olimex 40 pin boards with serial ports.
should I be using encoders instead ? The on pic adc would be nice

I would like the axes to have a position register that could be altered from a PC or pendant.

The arm controller would connect to a PC serial/printer/ethernet port doesnt matter really.
The controlling software will be vbasic.
 
Just some random thoughts or brainstorming ideas. I think a larger 18f 40pin would work, something like a 18f4620 or similar. This would be assuming that a serial connection to the PC is in the mix, and that a software motor control would work. Also, the two speeds would come from a pwm applied to a mosfet on the motor power supply(s).

Your goals seem to mix the need for both software and hardware motor control. The individual motor acceleration/deceleration is more of a hardware pwm thing I would think. Five pwm's would have to come from a 24f or? A 18f4331 has 4 pwm's or two 18f1330's would give you six.

All said and done maybe a 16 bitter would work out best. They have ones with really fast a-d (2Msps), and that may come in handy if you have to read a bunch of accelerometers to determine fixed or relative positions.

I like the basic syntax myself, which presumably is a minority view on this forum, suit yourself.

This is just a warm up till the true experts arrive on the scene.
 

Mr RB

Well-Known Member
I am building a 6 degree of freedom robot arm.

...

The list of functions would include:
acceleration/decceleration
station keeping (the elbow lowers when the shoulder is rising and needs to be compensated for)
home/park (find home safely on power up / alternate safe position)
hi speed / low speed

I have a variety of pics and the easy pic 4 with basic and c.
...

The arm controller would connect to a PC serial/printer/ethernet port doesnt matter really.
The controlling software will be vbasic.
This is not a trivial project! My first suggestion is to WIDELY separate the high level motor control functions from low level.

So the PIC; accepts serial command, turns motor to X position
The PC; does everything else; accel ramps, station keeping etc

The first task is to hook up the PIC to hbridge and pot and get a basic servo going to move the shaft to a position determined by the serial command. You only need a real simple system of ramping here as your arm is moving slow and it's better to do the "proper" motion control at the PC end. So you won't need full PID motor control in the PIC, and it would cause problems anyway as the PC will be trying to do that job!

Once you get one motor going ok you can probably use one PIC for all six motors as DC motors have best power on a lowish freq PWM (hundreds of Hz) anyway. Your hbridges only need 2 PIC pins so you only need 12 output pins, 6 AD inputs and 1 serial input. Generating 6 PWM and reading 6 AD inputs at a few hundred Hz should be easy enough, and as I said before you only need simple PWM ramping you won't need to do complex motion control math on the PIC.
 

urthlight

New Member
another goal

No it is not trivial, I have a lot of sweat invested already.
The suggested 18f4331 looks like a pretty good choice?
The ramp could be a simple curve (the longer the input pulse length the more rpms and then a coast down, just to dampen the jerkies).

I would also like for this pic have a boot-loader and be programable in place via serial port. My olimex boards do have an icsp and rs232 ports.

And, I love the part about not doing complex math on the pic.
 
Last edited:

Mr RB

Well-Known Member
No it is not trivial, I have a lot of sweat invested already.
The suggested 18f4331 looks like a pretty good choice?
I think any of the 18F series would have enough processing power because you can do the PWM manually, given a choice I would pick one with a high clock speed. Maybe 18F46K20?

The ramp could be a simple curve (the longer the input pulse length the more rpms and then a coast down, just to dampen the jerkies).
Input pulse length??? I would make the "input" to the PIC a serial command received by the PIC internal USART.

By "ramp" I meant the PIC measures the error between the shaft position (the pot) and the desired position, and has a simple linear ramp to control how much motor current is PWM'd depending on the error. Obviously for larger errors the motor is on full. This gives a crude deceleration to the destination, and you manually can add in an acceleration ramp.

The PC will take care of the rest, because it needs to know all the loads like the variable load payload and the angular position of all the axes to gravity which will affect static sag etc as the arm holds any final position.

So for the arm to move say 45' over 2 seconds the PC might send 50+ move commands over the serial to the PIC. So it's the PC side that does all the high level motion control. Your PIC's job is just a real simple closed loop servo driver, and the simpler it's characteristics are the better the PC can compensate for variable loads and static sag etc.
 

urthlight

New Member
Well, digging thru my stuff I found 2 18f4431 chips so I think I will use these.
They seem to have everything I need and the price is right(free samples from MC)

Here is my bootloader.
"Self-Programmable under Software Control"

Two good options here I am not sure about LIN1.2:
" Enhanced USART module:
Supports RS-485, RS-232 and LIN 1.2
Auto-wake-up on Start bit"


Many options for 5 or 6 motors :

"17.0 POWER CONTROL PWM MODULE

Multiple DC Brush Motors

The PWM module has the following features:

Up to eight PWM I/O pins with four duty cycle generators.

Up to 14-bit resolution, depending upon the PWM period.

On-the-fly PWM frequency changes.

four generators and eight channels on PIC18F4331/4431 devices. "


Lots of analog for really 5 axes (the gripper will be a whole other system)
"20.0 10-BIT HIGH-SPEED ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE

The A/D module supports up to 9 channels on the PIC18F4331/4431devices.

This high-speed 10-bit A/D module offers the following features:

Up to 200K samples per second

Selectable Simultaneous or Sequential Sampling modes

Operation in Sleep using internal oscillator"



This is very nice for future upgrades:

"16.0 MOTION FEEDBACK MODULE
with the Power Control PWM(PCPWM) module ( Section 17.0 ), it provides a variety of control solutions for a wide range of electric motors.

The module actually consists of two hardware submodules:
Input Capture (IC) " Beam Breaker?
"Quadrature Encoder Interface (QEI)"


Is there any reason to shop further?

I have 2 chips and boards, should I build a dedicated a/d board and a seperate for pwm?

What are the limitations of 4 generators 8 channels? Or another option would be to split half of the a/d and pwm and build 2 boards.

Much thought......

I guess I will put the boot loader on the back burner and start with the serial comms from the PC.

Dunno. Just trying to make as few mistakes as possible. Trying to build stuff that has got room to grow. Evolve the software, but I digress

Thanx for the advice.
 

Mr RB

Well-Known Member
I haven't used that PIC so I cant help much with that particular PIC, but it looks nice.

As for the inbuilt "power control PWM module" it only does 4 PWM outputs (ie only 4 motors).

So you can use 2 chips, or ignore the PWM module and manually generate the 6 pwm signals.

If you use 2 PICs you can just connect them both to the same serial input.
 

urthlight

New Member
Well, I have looked for examples or guidence on the 18f4431 and..... not even an led blink to get me started. Digging thru another container of parts i came across 8 mcp3204 dedicated a/d converter chips. I could go with a more conventional 40 pin and use 2 of these bad boys.
Or go with 452 or 4520 which I also have on hand
Any thoughts?
 
Last edited:
Seriously? No blinking led, and yet you are going for a 6 DOF robot arm:confused:.

Here is your blink led for your 18f4431 on an olimex board (led on PortA,0), in Great Cow Basic. Please start a different thread on the language/compiler wars, so I can avoid it.

You seem to be contradicting yourself, you have two 18f4431's and then you don't? Software pwm may work for you, or it may not. This chip and other variations like it give you more 'outs' if a hardware pwm becomes desirable.

I doubt many people have plowed the course you have set yourself on, so therefore little feedback. It may very well be a trial and error situation, unless you can latch onto a someone's completed project, and learn from that. Don't worry about how many chips and boards until the prototype is finished, especially if they are already at hand. When you have proven the concept, the finished product will reveal itself:).

Using the motor control module has been a back burner project for some time now, and will continue to be.

Code:
'Chip model 
#chip 18f4431,20
#config WDTEN=Off

#define Led PortA.0
dir PortA.0 out

Main:
Set Led On
wait 1 s
Set Led Off
wait 1 s
Goto Main
Simple a-d program.

Code:
'Chip model 
#chip 18f4431,20
#config WDTEN=Off, MCLRE=On
'Setup 4 bit LCD 
#define LCD_IO 4
#define LCD_DB4 PORTB.0
#define LCD_DB5 PORTB.1
#define LCD_DB6 PORTB.2
#define LCD_DB7 PORTB.3
#define LCD_RS PORTB.4
#define LCD_RW PORTB.5
#define LCD_Enable PORTB.6

dir PortA.1 in

Main:
 cls
  LCDWord ReadAD10(AN1)
  wait 50 10ms
Goto Main
 

urthlight

New Member
I have not been able to get any code to run on the 18f4431 so far but much success with other chips. Finding example code helps alot.

I cannot afford the time to learn another compiler, I have mikrobasic. I have what I have and will make the best of it.

Oh yes, I have 3 of the 18f4431 chips but im finding very little seed code. I got these for this project but if they are going to be so much trouble to use I have other options. At the same time, I secured The A/D chips The rs232 chips and the ethernet chips as well as a handful of other Pics.

No I can find no one that has built this and shared it. But there will always be a first.
I am sure that there will be much trial and error, that is why I am spending time on the decsions so that i can avoid as many pitfalls as possible.

So that is why I am here trying to share the concept, work and benefits of an open source robot arm made from standard plate stock, bar stock, cast off parts and trailing edge electronics.

All comments, insights or help are welcome.
 
Last edited:

grassm

New Member
for multiple H bridge PWM output dsPIC33F......series

I'm working on a project that requires several PWM channels. That's how I ended up here. I've worked with both the Atmel mega128 and the PIC18F4550. What I've found after several days of searching was the 16 bit dsPIC33F series of controllers that seem to be very well suited for controlling multiple DC brushed motors via PWM channels. I haven't played with one yet but I have one on order. The one I ordered has 8 PWM channels.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top