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.

motor controlling PIC16f877A LM293

Status
Not open for further replies.
pid profile motor

I'm away from my home computer for a couple of days but....When you're initializing your microcontroller, keep the "reset" signal to lm628 high. Then, when starting the reset routine, bring reset and CS low, goto delay route for a 20 milliseconds, Then bring reset high again, read and compare the status byte to hex "84", if equal reset was successfull, if not, compare status to "c4", if equal, you're successfull, if not try displaying the status byte to see what went wrong, or just go back and try again from initializing the micro. If you can't display the stat byte, just leave it in a loop at the read lm628 routine and measure the voltages on the data pins to determine the states. If reset was successfull, you then must reset the interupts (command "1d) before writing motion commands. After writing "1d" (reset interupts) you must again read the stat byte and compare it to "c0" or "80" to assure that was successfull. I don't have access to manuals or home computer until tomorro, I'll try to write a detailed sequence of events / commands.
 

ic pid

sorry for late reply,i just finish solder the circuit.. and troubleshoot.. and now i can concentrate more on programming.. the due date for my project is 16 march.. i hope i can finish it sooner.. still there is trouble with lm628.. when writing 16 bit data in data port of lm628,how long the delay that i should use between high byte and low byte? there is 3 input for encoder (in,A,B),which port should i use,i'm using 1 channel encoder..
 

pid oamp

I've attached code with comments and timing diagram with parameters written in and reference in code comments (like T8, T15..). If you understood the previous "code describe", you should have no trouble with this. Please ask if it's not clear.
The quadrature pins (A,B, Ind) on lm628 should connect to the motor encoder. You could also read them with the microcontroller, there is a routine in my code to display their states as " A, a, B, b, I, i" on the LCD. But if it's working right, you should just be able to read position from lm628 (command "0A") which would give you the results of the encoder counts. There's also a routine in my code that displays position automaticly after you jog the motor. It calls "WrtDWrd" to display position after detecting that the jog direction button is not pressed and stopping motor. This is why the "getD' (get data) routine reads 4 bytes from the lm628, because the position register is 2 words (32 bits), this is commented pretty well in the attachment. Pat
 

mc3phac applikation

pat,i've tried using a code similar to your but i still failed to reset interrupt because the value C0hex or 80hex not shown even though i try looping.. for reset is ok because lm628 gave value C4hex..
 

use lm628 with lmd18200

You are having very similiar experiance to mine when I was developing this code. I was getting status of c2 after reset (position error). So I ignored status and tried to move motor. It would start moving but not stop when I released the jog key, or it would stop and print position to LCD that would indicate it only moved 1 or 2 quadrature clicks. My problem turned out to be that I had soldered the A, B, & Ind wires from the encoder to the socket for LM628 while the chip was in, and burned out those inputs to my LM628. At first I suspected the encoders, so I wrote that code to read and display encoder stats. They worked fine, so I tried replacing my LM628 and everything was good.
Perhaps you have a similiar issue. If it reset OK, it is communicating correctly, so the status byte should provide some clue to the problem. Also, try displaying status byte after Reset Interupts, and then go to relative velocity move routine regardless of status and observe the motor behaviour, that may provide clues as well. Please let us know. Pat
 

74ls151 projet

sometime it show value c2hex too but it usually show c4hex value.. i put 5v on index and B input,A input i connect to encoder..
 

pid 1804 ic

I hope you remember that after writing the "1D" (reset interupts) command, you must check busy bit, then write "00" twice to reset all interupts. I think you should accept that C4 value for now and try to make a velocity or position move. If your write routine was not functioning, I think you would get a status indicating command error (C2). I don't write to the LM628 exactly the way the timing diagram shows, instead, I make CS low and PS hi (for data), then put the data on the pins, then strobe WRite low, then a short delay (at least 100nS), then WRite hi. In between each signal change, like CS and PS, I put a "NOP" (no operation) delay of one instruction cycle. I only load the filter value for proportion (Kp) in the LFIL command. Please let me know if you are successfull or other question. Pat
 

pid 4c06 ic

yeaa.. finally i get c0hex.. thanks pat.. but i had to put busy check between high byte and low byte.. is that ok? so now i can proceed to next subroutine..
 

p i d controller ic

You should only need to check Busy Bit after instruction write or after second byte. Maybe you just needed a delay between 1st & 2nd bytes. Anyway, yea, go for the motion coding, I think you're on the fast track to success! The way I did it was to use + and - jogging keys that displayed position after key released and motor stopped. Please let me know .
 

motor encoder code asm

now i know why i put busy bit check and succeed,because it has 'PS=0' from RDSTAT condition.. so i just need to put PS=0 after write 1 byte data.what do you means by using + and - ? can you show me and explain the simplest program to move motor from encoder..
 

picbasicpro pid routine

The "+" and "-" are keys on the keypad used to jog the motor in forward or reverse, this is how the robot is taught. I've attached the code for this with comments as usual. The first routine, "move" checks for + or _ key press and sends to cw or ccw routines, these initiate a velocity move and return to cwtst or ccwtst routines to wait for the key to not be pressed, then to stop routine, then to write position routine, then back to wait for another key pressed. The velocity and position move routines both load acceleration and velocity parameters. I realize this is not the simplest way to move , but it answers both of your questions. Please look this over and tell me if it's not clear enough. Pat
 

pic basic pid motor pwm

pat,for lm628,what value for DAC port for forward and reverse.. so far the output for DAC port is 00000001 binary.. how do i know that i've succeed in write filter coefficient,acceleration,velocity n position..
 

dual motor pid code -globalspec

From the datasheet;
"The LM628 DAC output port can be configured to provide
either a latched eight-bit parallel output or a multiplexed
12-bit output. The 8-bit output can be directly connected to a
flow-through (non-input-latching) D/A converter; the 12-bit
output can be easily demultiplexed using an external 6-bit
latch and an input-latching 12-bit D/A converter. The DAC
output data is offset-binary coded; the 8-bit code for zero is
80 hex and the 12-bit code for zero is 800 hex. Values less
than these cause a negative torque to be applied to the
motor and, conversely, larger values cause positive motor
torque."

So it should be binary 1000000, with the "1" on pin 18 (the Most Significant Bit) when commanded not to move. Binary 00000001 would mean maximum torque in the reverse direction... Unless it's configured for 12 bit mode...? I found that it defaults to 8 bit mode and never had to configure it either way, since I'm using 8 bit mode.
So if you're getting HEX 01 after commanding a reverse direction move, you probably are working correctly. If you're getting the 01 before a move command, maybe it's somehow configured itself into 12 bit mode? Does the status byte give any clues? like indicating command error, or trajectory complete?
Also, does the DAC you are using have differential outputs? like "out+" and "out-"? Because this is what the circuit assumes - that your DAC will have no current (0 Volts) between the outputs when binary 10000000 is apllied to the inputs.
 

ic 324 for dc motor

ooh.. sorry actually it is 1000000 binary.. like i told before,i just use another PiC to convert to pwm, before this i though 00000000 is motor off.. then it means that i still cannot move the motor.. i think my program failed to write Acceleration,Velocity and Position value..
 

bord lm628

Here's the sequence for an "absolute velocity move";
1E ;load filter, PS = low for instruction
BB ;check busy bit
00 ;PS = hi for data
18 ;means Kp only to be loaded
BB ;PS is low to check busy bit
00 ;Kp hi byte, PS hi for data
80 ; Kp low byte = dec255
BB ;PS is low to check busy bit
04 ; UDF (update filter) PS is low for instruction
BB ;PS is low to check busy bit
1F ;LTRJ (load trajectory) PS low
BB ;PS is low to check busy bit
18 ;PS is hi, 18 means absolute velocity, forward
28 ;means velocity and acc to be loaded
BB ;PS is low to check busy bit
00 ; Acc hi word, hi byte, PS is hi for data
00 ;Acc hi word, lo byte
BB PS is low to check busy bit
00 ; Acc lo wrd, hi byte
08 ; lo wrd, lo byte
BB ;PS is low to check busy bit
00 ;Vel hi word, hi byte, PS is hi for data
00 ;VHL
BB
0A ;VLH
4A ;VLL
BB
01 ;STT (start trajectory), PS is lo for instruction.
These bytes must be loaded by routines that pay strict attention to timing and bit state. Review the previous post with the timing diagrams and code. Remember; The Port Select bit must be high for data and low for instructions, also, you must use the "BB" busy bit check routine after each instruction and after writing or reading two data bytes. If you write the status byte to the display when you check the busy bit, then delay for a couple of seconds so you can read it, you will be able to troubleshoot easily and see the status as you go. If you want, I could send you a DAC or two, free of charge. I could also write the "position move sequence" in a similiar way.
You could use bit #8 (pin 18 ) of the LM628 output as a direction bit and then use the remaining 7 bits as PWM magnitude if you really want to continue using the other PIC for PWM. Please let me know how it's going. Pat
 

motor pid

pat.. my motor still cannot move.. i try to change some of program but failed.. :-( i has load the value for velocity=00 00 01 42,but then i read from RDDV= 00 08 07 07.should they have same value? or something wrong with my program when read or write..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top