View previous topic :: View next topic |
Author |
Message |
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Sun Dec 18, 2016 5:11 pm |
|
|
It all depends on if you need to use the diagnostics from the device.
You should always post your PIC type and basic code. Also have you made the PCB or bought something ?
Jay |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sun Dec 18, 2016 6:17 pm |
|
|
Typically you wouldn't need to disable half the bridge so the ENa and ENb
signal pins would be connected to PIC input pins.
The Enx pins are normally be pulled high via resistor and are pulled low
by the A or B bridge when a malfunction exists.
If you need to disable half the bridge for some reason you can change the
PIC pin to an output and pull it low. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 2:05 am |
|
|
Jay I didnt buy motor and driver yet ,this is why I couldnt sent ,When I got it I will write.
[/quote]The Enx pins are normally be pulled high via resistor and are pulled low
by the A or B bridge when a malfunction exists.
you mean I'll set mikrocontroller pin to input then I will pull high(what happining then in controller). |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Mon Dec 19, 2016 2:33 am |
|
|
First thing. One 'keyword' in the data sheet. 'Must'.
These pins _must_ be connected to pull up resistors.
Now the pins are useable in two different ways. The first is as diagnostic outputs from the chip. Connect them to two PIC pins, and program these as inputs. Then if something goes wrong you can read the voltages on these pins, to see what has happened. These are the Diag outputs.
The second way is if you pull them low, then they allow you to turn off each half of the bridge. ENa turns off half bridge 'A', and Enb, turns off half bridge 'B'. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 2:56 am |
|
|
Okay now I got it also with in Application Information. I will set input these ENx and externally pull high. But last one question, if the device generate problem, ENx pin pull low and PIC read 0, am I right? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Mon Dec 19, 2016 3:18 am |
|
|
Not quite that simple. This is the 'Table 12' truth table.
DiagA will go low
DiagB may go low or stay high in some circumstances. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 3:24 am |
|
|
Yes, I saw it, but how do I get the knowledge that the motor is going backwards or forward and speed because PID controller want this information to feedback ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Mon Dec 19, 2016 3:30 am |
|
|
You don't from this chip.
This is a driver, not a position sensor.
You need to add a position sensor to the motor. Typically a quadrature encoder.
Many years ago, I posted a fast quadrature decoder:
<http://www.ccsinfo.com/forum/viewtopic.php?t=40338&highlight=quadrature>
and the core code for an efficient integer PID:
<http://www.ccsinfo.com/forum/viewtopic.php?t=19703>
However these days it is much cheaper (and easier) to handle the quadrature using a hardware solution (either a PIC with built in quadrature decoding, or a chip that does this). |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 3:41 am |
|
|
I'm trying to understand that. I'm going to buy an engine with an encoder and I will drive it with this device. I understand that it will only drive it. Sorry my question was the previous one. I want to ask how to use the encoder output information exactly ? What I heard that the timer was used. İf my questions are bad, I'm sorry.
I will look your sites now. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Mon Dec 19, 2016 5:14 am |
|
|
Don't use/read the timer.
Instead, calculate the time interval you want to use for your servo. This will depend on the resolution of the encoder, the PWM frequency being used (you really want the interval to be synchronous to the PWM), the response time, how long the maths will take, etc. all the parameters already mentioned.
Once you have worked out what this interval has to be, work out a way of generating a 'tick' at this interval.
Then have your code perform the servo functions when this tick triggers.
Now the key thing then is that delatT then becomes a constant. Suddenly not needed in the maths at all. You can just build the constant corresponding to this, 'into' the servo factors (for instance Kp, can just be stored as Kp/delatT). All the 'delatT' figures can disappear from the maths the processor has to perform.
Study some PID examples. MicroChip have several.
They all keep deltaT constant for this reason. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 5:43 am |
|
|
One more question, what is meant here ?
Low High High Low
High High Low Low -->count =1 or
Low High
High High --> count = 1
This gearmotor is a powerful 12V brushed DC motor with a 30:1 metal gearbox and an integrated quadrature encoder that provides a resolution of 64 counts per revolution of the motor shaft, which corresponds to 1920 counts per revolution of the gearbox’s output shaft. These units have a 0.61"-long, 6 mm-diameter D-shaped output shaft. This gearmotor is also available without an encoder. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Mon Dec 19, 2016 6:22 am |
|
|
By the way, the IMU will be in the program and will be fed the motor with PID according to IMU.
DeltaT is now calculated according to gyroscope, so Kalman Filter works correctly, in this case I think that if the PID and the other calculations are included again. DeltaT according to gyroscope will be a system's deltaT, right? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Mon Dec 19, 2016 8:07 am |
|
|
First don't get hooked on PID.
PID can be a good starting point, but in many cases is not the best algorithm for system control. You will find there are other variants some to catch things faster PID^2 for example, and other omitting some terms (PD for example).
Now what you are describing may well need to bring the motor itself 'outside' the main control loop. Problem is that if you choose the loop to suit the IMU, the time involved may well be too slow for good control of the motor. Commonly systems like this, have a 'simplified' motor control, (typically omitting the I term, since the IMU will handle the integral error), with the motor system itself then able to accept motor movement commands (often 'to where' & 'at what maximum speed'), with it's own independant control loop). Trying to put too many things in one loop is a sure way to end up with problems like oscillation, as you get interference effects from the time constants of all the sub components. This is why things like multi-copters, have several separate control loops often with correction from other slower loops outside. |
|
|
|