Today I worked on wiring and programming in multiple encoders. I spend most of the first hour wiring it in. Silly me, didn't check to see if the connectors were attached fully to the input wires. Waste of 45 minutes. The next 20 minutes were spent determining what data from the encoder was required for the program. Tests have shown that the program needs all 3 channels from each encoder to be fully operational.
The wires just for 2 encoders was already at 10. On Day 30 (which will hopefully be Wednesday [a non-class day]), I'll relearn the connector plugs to cut down on the required wires for operation. Then on Day 31, I should be all set to set up and execute 2+ encoders with the program with a much more tidy wiring setup.
Tuesday, February 28, 2012
Monday, February 27, 2012
Day Twenty-Eight
Went over the specifications and schematics of the Motor Mind B - enchanced board with Eric Ard to determine programming requirements for when we receive the boards. (Teacher purchased a board for each group.) As I was doing that all of class period, I have not yet worked on getting the 5 encoders to work simultaneously with my board/program. It's put off for Day 29.
Wednesday, February 22, 2012
Day Twenty-Seven
Now that I have a working program for the direction and count, I will be furthering the code/circuitry by adding more encoders. Woot! This will require my figuring out if both Channel-A and Channel-B are require for the initial program, then adding channels from 1 additional encoder. After that is successful, I shall keep adding encoders (and wiring, egads!) until all 5 encoders are wired in and counting (with direction) perfectly.
Hmm I said I would upload pictures and haven't yet... Maybe monday, as I will need to upload the final wiring and circuitry for this program.
Note: Technically tomorrow is Day Twenty-Seven, but class is cancelled for Day Twenty-Seven and Twenty-Eight. Thus, I shall work today as if were Day Twenty-Seven! ^_^
Edit: didn't get it all figured out, will continue on Monday.
Hmm I said I would upload pictures and haven't yet... Maybe monday, as I will need to upload the final wiring and circuitry for this program.
Note: Technically tomorrow is Day Twenty-Seven, but class is cancelled for Day Twenty-Seven and Twenty-Eight. Thus, I shall work today as if were Day Twenty-Seven! ^_^
Edit: didn't get it all figured out, will continue on Monday.
Tuesday, February 21, 2012
Day Twenty-Six
Tinkered with that Quadrature Encoder program from my previous post. I'm fixing the bugs in it. Hopefully it'll work completely or at least to some degree before 3pm today.
Edit: it's now 2pm and I've gotten the program to work. It shows current position and the change in position. (YAY!! we have direction now!) The change in position is either positive or negative number with the amount of change from previous to current position. The output is FAST. So fast, in fact, that I need to slow down the output on the screen, just to be able to read it. O_O Awesome!
Larry helped me with getting the program to output to the Terminal Program.
Edit: it's now 2pm and I've gotten the program to work. It shows current position and the change in position. (YAY!! we have direction now!) The change in position is either positive or negative number with the amount of change from previous to current position. The output is FAST. So fast, in fact, that I need to slow down the output on the screen, just to be able to read it. O_O Awesome!
Larry helped me with getting the program to output to the Terminal Program.
Monday, February 20, 2012
Day Twenty-Five
Had meeting today on what needed to get done this week. I'm going to continue working on incorporating the Z-channel to show direction of movement, with A- and B-channels doing the counting. I think.
Edit: Scratch the Z-channel; it wont tell direction. Moved onto a tangent. Found a Quadrature_Encoder program that can control 16 encoders at once. I'm using its example code to fashion a usable program from it.
{{
* File: ReadEncWithQuad.Spin
* Name: Palak Shah
* Date: February 20, 2012
*
* Desc: Attempt to read the values recorded by the microcontroller
* as inputted by the encoder.
}}
CON
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
OBJ
Encoder : "Quadrature Encoder"
FDSP : "FullDuplexSerialPlus"
VAR
long Pos[6] 'Create buffer for 5 encoders (plus room for delta
'position support of 1st encoder)
long AbsPos, Delta1
PUB Init
Encoder.Start(20, 5, 1, @Pos)
'Start continuous two-encoder reader (encoders
'connected to pins 20-26)
PUB Main
Comm
repeat
AbsPos := Pos[0] 'Read each encoder's absolute position
Delta1 := Encoder.ReadDelta(0) 'Read 1st encoder's delta position
' (value since last read)
Output
PUB Comm
FDSP.Start (31,30,0,57600)
waitcnt(clkfreq * 3 + cnt)
FDSP.tx(16)
FDSP.str(String("'Encoder Reader' by Palak Shah"))
FDSP.tx (13)
FDSP.tx (13)
PUB Output
FDSP.bin(AbsPos, 16)
FDSP.tx (13)
FDSP.bin(Delta1, 16)
FDSP.tx (13)
Edit: Scratch the Z-channel; it wont tell direction. Moved onto a tangent. Found a Quadrature_Encoder program that can control 16 encoders at once. I'm using its example code to fashion a usable program from it.
{{
* File: ReadEncWithQuad.Spin
* Name: Palak Shah
* Date: February 20, 2012
*
* Desc: Attempt to read the values recorded by the microcontroller
* as inputted by the encoder.
}}
CON
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
OBJ
Encoder : "Quadrature Encoder"
FDSP : "FullDuplexSerialPlus"
VAR
long Pos[6] 'Create buffer for 5 encoders (plus room for delta
'position support of 1st encoder)
long AbsPos, Delta1
PUB Init
Encoder.Start(20, 5, 1, @Pos)
'Start continuous two-encoder reader (encoders
'connected to pins 20-26)
PUB Main
Comm
repeat
AbsPos := Pos[0] 'Read each encoder's absolute position
Delta1 := Encoder.ReadDelta(0) 'Read 1st encoder's delta position
' (value since last read)
Output
PUB Comm
FDSP.Start (31,30,0,57600)
waitcnt(clkfreq * 3 + cnt)
FDSP.tx(16)
FDSP.str(String("'Encoder Reader' by Palak Shah"))
FDSP.tx (13)
FDSP.tx (13)
PUB Output
FDSP.bin(AbsPos, 16)
FDSP.tx (13)
FDSP.bin(Delta1, 16)
FDSP.tx (13)
Day Twenty-Four
Worked on getting the Z-channel programmed in, not sure how it's supposed to be incorporated, thus failed at this today. Will work on that on Monday (Day Twenty-Five).
Thursday, February 16, 2012
Day Twenty-Three
Today I tinkered with the code that does a better increment without using assembly. Tinkered cuz it STILL doesn't work properly. But in this case, while it can keep up with the speed of the arm, both directions doesn't count in their own direction. Like Channel A is ++ and Channel B is --, but it only counts ++ or -- depending on the code setup.
The current code for counting is as follows:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5000000
Ao = 20
Bo = 21
VAR
long counter
PUB Main | newBits, oldBits, direction
dira[Bo..Ao]~
dira[1..16]~~
oldBits := ina[Bo..Ao]
counter := 0
repeat
outa[1..16] := counter/1000
newBits := ina[Bo..Ao]
if newBits <> oldBits
direction := (newBits & %1) * (oldBits >> 1)
case direction
0 : counter++ 'one direction works perfectly but the
1 : counter-- 'other doesn't when the first does work.
oldBits := newBits
The current code for counting is as follows:
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5000000
Ao = 20
Bo = 21
VAR
long counter
PUB Main | newBits, oldBits, direction
dira[Bo..Ao]~
dira[1..16]~~
oldBits := ina[Bo..Ao]
counter := 0
repeat
outa[1..16] := counter/1000
newBits := ina[Bo..Ao]
if newBits <> oldBits
direction := (newBits & %1) * (oldBits >> 1)
case direction
0 : counter++ 'one direction works perfectly but the
1 : counter-- 'other doesn't when the first does work.
oldBits := newBits
Tuesday, February 14, 2012
Day Twenty-Two
Learned that using Count++ and Count-- as counters were too slow for the movement of the robotic arm. So I am now learning about CTRA and CTRB as much faster counters to count the pulse edges of the outputted encoder pulses. Prior to this, the code is 5 lines long. And too slow. Gotta work on efficiency of the code. If that fails, then I will hafta self teach (maybe some professor help) myself Assembly for SPIN.
Monday, February 13, 2012
Day Twenty-One
Programming in 2 channels, so that the microcontroller can see forward and backwards. Then with that knowledge we can incorporate Dave/Eric's work with PWM into that. Thus the computer program can control voltages to move the arm servos forwards/backwards.
Friday, February 10, 2012
Day Twenty
Today I got my program to count each pulse, had to use all 16 LEDs on the microcontroller. Now I shall work on making it count forwards and backwards. Taking input from both channel A and B. In this way we can see our exact position regardless of which way we're moving. The circuit is the same for each channel. Programming SHOULD be relatively easy.
Thursday, February 9, 2012
Day Nineteen
O_O it blew up... omg.
just kidding.
Today i did get the circuit working, eventually. (took about 1.75 hours to get all the kinks outta the program, wiring and solving my grounding issues.) The LED on the microcontroller now flashes with every pulse. Tomorrow I'll do a test run to see if the 2nd program I wrote correctly counts each pulse. If it does, then I'll have what i set out to do this week done. Yay!!
just kidding.
Today i did get the circuit working, eventually. (took about 1.75 hours to get all the kinks outta the program, wiring and solving my grounding issues.) The LED on the microcontroller now flashes with every pulse. Tomorrow I'll do a test run to see if the 2nd program I wrote correctly counts each pulse. If it does, then I'll have what i set out to do this week done. Yay!!
Day Eighteen
Today I set up the circuit on the microcontroller board to test the encoders. First circuit test was to see if the directed output from the encoder caused the LED light on the microcontroller to turn on. I didn't complete the circuit in time to test this. For creating the circuit, I had no idea what i was doing and got a little help from Dave. On Day Nineteen, I will actually get to see if the circuit works or not.
Note to self: upload pictures.
Monday, February 6, 2012
Day Seventeen
Dave isn't here today, so I cant assist him. So I will work on getting the microcontroller board to light up an LED when it receives a pulse signal. Then, later to be able to count the pulses from each channel (A and B).
http://www.arrickrobotics.com/arobot/edled.html
http://ikalogic.com/tut_closed_loop_spd_ctrl.php
http://www.societyofrobots.com/robotforum/index.php?topic=13192.0
http://www.robotstorehk.com/motordrivers/motordrivers.html
http://www.arrickrobotics.com/arobot/edled.html
http://ikalogic.com/tut_closed_loop_spd_ctrl.php
http://www.societyofrobots.com/robotforum/index.php?topic=13192.0
http://www.robotstorehk.com/motordrivers/motordrivers.html
Day Sixteen
I attempted to be useful today, but due to my severe cold, I couldn't concentrate on anything for very long. Low attention span? I will assist Dave and Eric F. on Monday with the program-to-arm-manipulation.
Thursday, February 2, 2012
Day Fifteen
I spent the day programming/modifying code. Also, I investigated hardware that could help make the programming simpler.
http://www.parallax.com/tabid/768/ProductID/64/Default.aspx
http://www.electronickits.com/kit/complete/motor/k166.htm
http://www.parallax.com/tabid/768/ProductID/64/Default.aspx
http://www.electronickits.com/kit/complete/motor/k166.htm
Subscribe to:
Comments (Atom)