profmason.com

October 29, 2015

PM-940 CNC

Filed under: Daily — profmason @ 6:23 am

I haven’t read much about this mill so thought I would share a few thoughts.

Semi-random thoughts:
1. A 2 ton engine crane worked a trick for unloading and 3 of us had the mill uncrated, and up on the stand in about 90 minutes.   We didn’t need to cut the pallet down, just cut one of the supports on the pallet so we could work the crane under it and up it went.
2. Removing the z-axis way covers was a pain and required taking tilting the head 45 degrees. It needed to be trammed anyway so no loss.
3.  Fit and finish is ok. Almost every bolt we got to was loose.  X axis had lots of backlash and I spent an hour with shims until I figured out how to take it out on the end where the stepper couples to the lead screw.  It seems like a box of screws was missing so I spent some time hunting up the appropriate M3, M4, M5 and 10-32 bolts to attach the steppers.
4. The stepper drivers had some goofy settings. I guess china uses a different set of definitions for positive travel then we do?  The drivers also required the correct setting on current limiting and microstepping.
5.  The VFD required some setup, but once worked through it and the spindle is really smooth.
6. The draw bar!  I do not understand such a mickey mouse thing on a nice mill like this?  Are they all like this with a cheesy pinned nut and the draw bar is undersized so does the hula when the when the mill is running. Yikes!
7. The software was pure Chinese, but I was able to set it up in mach 3 (in english!) over about 6 hours. Matt send me a “brain” file that got the rest of the pendant working.  The pendant works, and is much better then nothing, but an aftermarket solution will really improve things.
8.  The scariest thing is that the machine has “cycle started” on its own at least 3 times with no one near the controller or computer. Each time an operator was there and could shut things down before a crash but this bare some investigation.   Hopefully it is just associated with the control pendant.
It took about 15 hours of work to start making parts.  Right now I am running at 200ipm rapids on X and Y and 150 on Z. Just cut UHMW and 6061 so far so no real tests of rigidity, but am making the parts that I need.
Bottom line:
1.  Compared to the Tormach this is a much beefier machine.
  • Much larger travels.
  • Much more massive.
  • It should be able to do much more then I could do on the Tormach!  The travels are about the same as the Haas TM1.  This machine doesn’t have the weight or rigidity of the haas, but for a hobby machine, where we run slower it will hopefully do well.
2. This machine is not for a neophyte.  If you haven’t owned a mill and setup a CNC machine before or have access to a lot of on site help that is relatively sophisticated on control systems, stay away.  There is no manual, no instructions etc.  I am glad I had a bunch of experience and have compatriots who also have good experience and intuition.
I haven’t got all the chinese grease off the machine, and am waiting for the 585XL to arrive to test the flood so there is still much more to see.

October 14, 2015

Characterizing popular beetleweight motors

Filed under: Daily — profmason @ 3:04 am

Three popular beetleweight motors are characterized below.   Motors were measured using a callibated hall effect balance. RPM were measured with a relfection base RPM unit.

  • China 1000 rpm motor.  77 grams+- 1  Measured rpm at 12V 1120 +- 10 

This motor uses a all steel spur gear box and has been extensively tested in beetleweight combat robots.  In particular robot Wicked Kitty has run them for 3 years in 11 events and over 50 fights.  It this time, one gear box has failed due to a gear shattering. This motor is available from Pete Smith via the kitbots.com website from ebay.  Pete has a recommended process for “battle hardening” these motors.   These motors are regularly run at 12V.
At first look, it appears that these motors are geared to high for a typical insect weight combat robot arena which is 6-8 feet on a side.   Running these motors into a 3″ wheel with a 3S battery at 12V nominal yields the following:
Torque (per motor) to spin wheels: 28.8 oz-in
Amps (per motor) to spin wheels: 1.98 Amps
Theoretical Top Speed: 9.96 MPH
Total Peak Amps: 3.97 Amps
Amp Hours Required – 3 Min: 0.139 AH
Amp Hours Required – 5 Min: 0.231 AH
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 9.96 mph
Arena Size (feet)
Time to Top Speed: 3.41  sec
Distance to Top Speed: 30.3  feet
Top Speed, Side-to-side: 6.30  mph
Time to Side: 1.50  sec
Top Speed, Corner-to-Corner: 7.04  mph
Time to corner: 1.84  sec
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 9.96 mph
Arena Size (feet)
5

Time to Top Speed: 4.06  sec
Distance to Top Speed: 33.3  feet
Top Speed, Side-to-side: 4.67  mph
Time to Side: 1.32  sec
Top Speed, Corner-to-Corner: 5.36  mph
Time to corner: 1.61  se
As the distance to Top speed is 30 feet, this system is not well matched to the size of the arena.  Going down to a 2S battery decreases performance slightly:
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 6.64 mph
Arena Size (feet)
Time to Top Speed: 2.80  sec
Distance to Top Speed: 15.0  feet
Top Speed, Side-to-side: 4.77  mph
Time to Side: 1.90  sec
Top Speed, Corner-to-Corner: 5.25  mph
Time to corner: 2.34  sec
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 6.64 mph
Arena Size (feet)
5

Time to Top Speed: 2.27  sec
Distance to Top Speed: 13.4  feet
Top Speed, Side-to-side: 4.68  mph
Time to Side: 1.22  sec
Top Speed, Corner-to-Corner: 5.18  mph
Time to corner: 1.51  se
  • China Aluminum Planetary 500 rpm motor: 67 grams +-1 Measured rpm at 12V 430 +-1 rpm
This motor was selected by team Robotics Wife Life  to run on their beetleweight Murder Nurse.  In my testing gearhead is extremely noise and the motor itself is of poor quality, heating up at 12V during the short duration of the test.  The planetary gears in the first stage are nylon and the second stage is brass.  These gears are just under 5mm in diameter.   This motor became hot at 12V and is apparently rated for 6V.  The brushes also started to show evidence of failure at 12V.
  • Pittman PG6212 with 23×1 steel planetary gearhead 88 grams Measured rpm at 12V 384 +1 10 rpm
The motor will be used in team bad kitty beetleweight big fat cat as part of a 4 wheel drive system.  The gear head on the this bot appears to be of high quality with a steel ring gear and all 7mm brass planetary gears.  The motor was run at up to 24V with out evidence of substantial stress.
Given that we run this motor on 3S into a 2 3″ wheel drive system you obtain the following results:
Torque (per motor) to spin wheels: 28.8 oz-in
Amps (per motor) to spin wheels: 0.68 Amps
Theoretical Top Speed: 3.42 MPH
Total Peak Amps: 1.36 Amps
Amp Hours Required – 3 Min: 0.047 AH
Amp Hours Required – 5 Min: 0.079 AH
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 3.42 mph
Arena Size (feet)
8
Time to Top Speed: 0.59  sec
Distance to Top Speed: 2.12  feet
Top Speed, Side-to-side: 3.31  mph
Time to Side: 1.79  sec
Top Speed, Corner-to-Corner: 3.31  mph
Time to corner: 2.48  sec
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 3.42 mph
Arena Size (feet)
5

Time to Top Speed: 0.59  sec
Distance to Top Speed: 2.12  feet
Top Speed, Side-to-side: 3.31  mph
Time to Side: 1.18  sec
Top Speed, Corner-to-Corner: 3.31  mph
Time to corner: 1.60  sec
The time to side is slower then the 3S 1000 RPM motor for the 8ft arena but faster for the 5ft arena.   We also know that we can run this motor at 4S:
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 4.56 mph
Arena Size (feet)
8
Time to Top Speed: 0.66  sec
Distance to Top Speed: 3.19  feet
Top Speed, Side-to-side: 4.46  mph
Time to Side: 1.39  sec
Top Speed, Corner-to-Corner: 4.46  mph
Time to corner: 1.90  se
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 4.56 mph
Arena Size (feet)
5
Time to Top Speed: 0.66  sec
Distance to Top Speed: 3.19  feet
Top Speed, Side-to-side: 4.46  mph
Time to Side: 0.93  sec
Top Speed, Corner-to-Corner: 4.46  mph
Time to corner: 1.25  sec
This is better performance then the 3S 1000 RPM motor.   Finally, running at 5S (20V)

Acceleration: Time and Distance to Speed

Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 5.71 mph
Arena Size (feet)
8
Time to Top Speed: 0.72  sec
Distance to Top Speed: 4.31  feet
Top Speed, Side-to-side: 5.60  mph
Time to Side: 1.16  sec
Top Speed, Corner-to-Corner: 5.60  mph
Time to corner: 1.57  sec
Weight Effective Pushing Force Top Speed
3 lbs 2.40 lbs 5.71 mph
Arena Size (feet)
5
Time to Top Speed: 0.72  sec
Distance to Top Speed: 4.31  feet
Top Speed, Side-to-side: 5.60  mph
Time to Side: 0.80  sec
Top Speed, Corner-to-Corner: 5.60  mph
Time to corner: 1.05  sec
Really great performance!  The conclusion is that the Pittman motors are much better matched to the arena size as compared to the the 1000RPM motors and encourage us to run at higher battery cell counts.

October 8, 2015

Useful Brushless Motor data

Filed under: Daily — profmason @ 6:49 am

Brushless motors are often rated in term of “Turns” which refers to some arbitrary number of turns of wire in the motor.  However, this is not a useful designation when it comes to determining motor performance.

There are two useful data for determining a suitable motor for your robot.

  1. Speed Constant  radians per second / Volt  (Rad / S / Volt) or revolutions per minute / Volt (RPM / Volt)
  2.  Torque Constant newton meters / Amp( Nm / amp)   or  ounce inches / amp (oz-in/amp)

The speed constant has SI Units of (Rad / S) / Volts. This can be calculated by taking the no load speed (rpm) and converting it to radians per second.  Divide this number by the rated voltage of the motor.   In practice, take a piece of reflective tape about an inch long and paint half of it black. Wrap this around the shaft.  Use a servo tester, ESC and spin the motor up to maximum.  Measure the RPM of the motor with your laser tachometer and then divide that number by the measured voltage of the battery .  This will give you a direct measurement of RPM / Volt.  Multiply by 0.1047 to convert to Rad/S / Volt.

The torque constant can by measuring the current draw at a given torque.  In practice this is difficult to do.   However, this number can be calculated from the Speed constant.  The torque constant is just 1 / speed constant.  However, this only works in SI units.  So the Torque constant in (Nm / Amp) = 1 / Speed Constant in(Rad / S / Volt).  Sadly we don’t tend to use SI unit on this side of the pond to to convert RPM / Volt to oz-in / amp we do the following.

  • torque (oz-in / A) = 1352.9 / (RPM / Volt)

Here are some example motors that we use regularly:

hobbyking trackstar 21.5 Turn sensored Motor

Can Size: 540
Turns: 21.5
RPM/v: 1855kv
Sensored: Yes (Standard 6 pin harness)
Max voltage: 7.4 (2S)
Max Current: 22A
Max Watts: 150w
Can Diameter: 36mm
Can Length: 53mm
Shaft Size: 3.175mm
Weight: 177g

1855 RPM/v gives a torque constant of 0.73 oz-in / amp.  With the numbers for the speed constant and the torque constant we can use the team tentacle torque calculator for any motor.

In a 15lb robot with the drive operating on 2S (8V nominal) with 1 motor per side driving a 16×1 gear box into 5″ wheels we get the following results given a coefficient of friction of 0.8:

Torque (per motor) to spin wheels: 15 oz-in
Amps (per motor) to spin wheels: 20.5 Amps
Theoretical Top Speed: 13.7 MPH
Total Peak Amps: 41.0 Amps
Amp Hours Required – 3 Min: 1.438 AH
Amp Hours Required – 5 Min: 2.397 AH
Weight Effective Pushing Force Top Speed
15 lbs 12 lbs 13.7 mph
Arena Size (feet)
Time to Top Speed: 5.14  sec
Distance to Top Speed: 61.0  feet
Top Speed, Side-to-side: 7.07  mph
Time to Side: 1.74  sec
Top Speed, Corner-to-Corner: 8.03  mph
Time to corner: 2.10  sec

We orginally ran 20×1 in this robot, but as those gearboxes have become unavailable, we have had to switch to 16×1 . This has proven to be an adequate combination in competitions but we can see that there is room for optimization as we are not nearly reaching the potential speed of the robot given the size of the arena.

Overvolting these same motors to 3S (12 V nominal) changes the parameters as follows:

Weight Effective Pushing Force Top Speed
15 lbs 12 lbs 20.6 mph
Arena Size (feet)
10
Time to Top Speed: 6.12  sec
Distance to Top Speed: 118.  feet
Top Speed, Side-to-side: 9.04  mph
Time to Side: 1.39  sec
Top Speed, Corner-to-Corner: 10.3  mph
Time to corner: 1.68  sec

This is not a large change in practice as the arena size limits the ability to get to top speed.  Due to the power constraints of the robot we have continued to run on 2S.

For the recently completed Armadillo kit we are using 550 mabu10chi motors into the same 16×1 gear boxes powered by 2S batteries. This robot runs 3″ wheels which are not as sticky as the banebots greens that are run on the above robots.  This gives the following results.


Torque (per motor) to spin wheels: 7.87 oz-in
Amps (per motor) to spin wheels: 7.64 Amps
Theoretical Top Speed: 8.76 MPH
Total Peak Amps: 15.2 Amps
Amp Hours Required – 3 Min: 0.535 AH
Amp Hours Required – 5 Min: 0.891 AH
Weight Effective Pushing Force Top Speed
15 lbs 10.5 lbs 8.76 mph
Arena Size (feet)
Time to Top Speed: 1.28  sec
Distance to Top Speed: 11.6  feet
Top Speed, Side-to-side: 8.44  mph
Time to Side: 1.3  sec
Top Speed, Corner-to-Corner: 8.55  mph
Time to corner: 1.6  sec
The Armadillo kitbot is nicely matched the arena, and actually has a lower time to traverse the arena since the brushed motors have more torque at the low end then the brushless motors.
However, we are looking at building a drivetrain for a 60lb robot.  Using the original trackstar 21.5x into the 16×1 gearbox in a 60lb with 4″ wheels yields the following.  Overvolting these motors about 3S would make one nervous, so lets leave it at 3S.  The results are below:

Torque (per motor) to spin wheels: 48 oz-in
Amps (per motor) to spin wheels: 68.2 (exceeds stall)  Amps
Theoretical Top Speed: 16.5 MPH
Total Peak Amps: 136. Amps
Amp Hours Required – 3 Min: 4.779 AH
Amp Hours Required – 5 Min: 7.965 AH
This is clearly not going to work as these motors can’t handle 67Amps.   So we need either bigger drive motors or taller gearing.
Switching to the turnigy trackstar 1/8 scale 1900KV motor allows us to run higher voltage and thus higher current. Here is the results of running the same 16×1 gearboxes at 4S.

Torque (per motor) to spin wheels: 48 oz-in
Amps (per motor) to spin wheels: 67.5 Amps
Theoretical Top Speed: 22.6 MPH
Total Peak Amps: 135. Amps
Amp Hours Required – 3 Min: 4.725 AH
Amp Hours Required – 5 Min: 7.876 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 22.6 mph
Arena Size (feet)
Time to Top Speed: 7.06  sec
Distance to Top Speed: 146.  feet
Top Speed, Side-to-side: 14.2  mph
Time to Side: 2.88  sec
Top Speed, Corner-to-Corner: 15.9  mph
Time to corner: 3.53  sec
The larger Arena reflects Dave’s arena at robogames as opposed to the NTMA arena for the smaller bots. While this motor can drive this drive system, it is very poorly optimized.
Dropping to 3″ wheels makes a small improvement, but it may be difficult to run 3″ wheels on a 60lb bot, fit everything and still be invertible. Here is the data with 3″ wheels.

Torque (per motor) to spin wheels: 36 oz-in
Amps (per motor) to spin wheels: 50.6 Amps
Theoretical Top Speed: 16.9 MPH
Total Peak Amps: 101. Amps
Amp Hours Required – 3 Min: 3.544 AH
Amp Hours Required – 5 Min: 5.907 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 16.9 mph
Arena Size (feet)
Time to Top Speed: 4.44  sec
Distance to Top Speed: 72.8  feet
Top Speed, Side-to-side: 13.8  mph
Time to Side: 2.73  sec
Top Speed, Corner-to-Corner: 14.8  mph
Time to corner: 3.41  sec
This is a bit better matched, but we are not nearly reaching the top speed of the robot. Adding another cell just increases the top speed and doesn’t solve any other problems.  Either we need to run a lower KV motor OR run a steeper gearbox.  The next jump in gear box for this size motor is 38×1!  This means we are adding another stage and lose another 8% in efficiency.   Lets look at the numbers 4″ Wheel, 16V, 38×1 gear box.
Torque (per motor) to spin wheels: 20.2 oz-in
Amps (per motor) to spin wheels: 28.4 Amps
Theoretical Top Speed: 9.51 MPH
Total Peak Amps: 56.8 Amps
Amp Hours Required – 3 Min: 1.989 AH
Amp Hours Required – 5 Min: 3.316 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 9.51 mph
Arena Size (feet)
Time to Top Speed: 1.98  sec
Distance to Top Speed: 19.1  feet
Top Speed, Side-to-side: 9.09  mph
Time to Side: 3.16  sec
Top Speed, Corner-to-Corner: 9.09  mph
Time to corner: 4.25  sec
Terrible! We have to run a higher KV motor to match the higher gearing.  If we switch to a 2400KV motor at 38×1 into the 4″ wheels here is what we get:

Torque (per motor) to spin wheels: 20.2 oz-in
Amps (per motor) to spin wheels: 35.8 Amps
Theoretical Top Speed: 12.0 MPH
Total Peak Amps: 71.7 Amps
Amp Hours Required – 3 Min: 2.512 AH
Amp Hours Required – 5 Min: 4.188 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 12.0 mph
Arena Size (feet)
Time to Top Speed: 2.51  sec
Distance to Top Speed: 30.7  feet
Top Speed, Side-to-side: 11.4  mph
Time to Side: 2.77  sec
Top Speed, Corner-to-Corner: 11.4  mph
Time to corner: 3.63  se
This is better matched, and the peak current is much healthier.  The motor is building about 570W which is well within its capabilities. Given two motors and 75% efficiency this is 855W to move 60 pounds along the floor which is why the top speed is what it is.
There may be an option for banebots to build a custom 26×1 gearbox.  This seems optimal for our purpose.  Here are the numbers with switching back to the Trackstar 1900 sensored into the 26×1 gearbox into 4″ wheels.

Torque (per motor) to spin wheels: 29.5 oz-in
Amps (per motor) to spin wheels: 41.5 Amps
Theoretical Top Speed: 13.9 MPH
Total Peak Amps: 83.0 Amps
Amp Hours Required – 3 Min: 2.908 AH
Amp Hours Required – 5 Min: 4.846 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 13.9 mph
Arena Size (feet)
Time to Top Speed: 2.17  sec
Distance to Top Speed: 31.9  feet
Top Speed, Side-to-side: 13.5  mph
Time to Side: 2.33  sec
Top Speed, Corner-to-Corner: 13.5  mph
Time to corner: 3.06  sec
Therefore it seems like the strongest combination assuming 4″ wheels for the 60lb is to use:
http://www.hobbyking.com/hobbyking/store/__22409__Turnigy_TrackStar_1_8th_Sensored_Brushless_Motor_1900KV.html
http://www.banebots.com/product/P60C-55.html
It is a question if this is possible with the 775 series motor.
The second best option is to use.
http://www.hobbyking.com/hobbyking/store/__32125__Turnigy_TrackStar_1_8th_Sensored_Brushless_Motor_2400KV.html
http://www.banebots.com/product/P60S-333-57.html
A final option is to run 4x drive using the 16×1 550 motors
Torque (per motor) to spin wheels: 24 oz-in
Amps (per motor) to spin wheels: 32.8 Amps
Theoretical Top Speed: 16.5 MPH
Total Peak Amps: 131. Amps
Amp Hours Required – 3 Min: 4.602 AH
Amp Hours Required – 5 Min: 7.671 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 16.5 mph
Arena Size (feet)
Time to Top Speed: 2.68  sec
Distance to Top Speed: 46.8  feet
Top Speed, Side-to-side: 15.5  mph
Time to Side: 2.18  sec
Top Speed, Corner-to-Corner: 16.0  mph
Time to corner: 2.80  sec
This is slightly better then running the two wheel drive.  The weight penalty would be substantial.
Cost is roughly the same.  For 5 motors and gearboxes it would be about $600 for drive train components.
I had concerns about running the 550 size motors due to the high current.  One of my team mates suggested that this was nonsense and the motors can handle much higher amounts of current for a short time.  (IE 3 minute match)   Here is running one of the 550 1855 RPM / Volt motors with a 26×1 gearbox at 12V into a 4″ wheel.

Torque (per motor) to spin wheels: 29.5 oz-in
Amps (per motor) to spin wheels: 40.5 Amps
Theoretical Top Speed: 10.1 MPH
Total Peak Amps: 81.0 Amps
Amp Hours Required – 3 Min: 2.836 AH
Amp Hours Required – 5 Min: 4.727 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 10.1 mph
Arena Size (feet)

Time to Top Speed: 3.53  sec
Distance to Top Speed: 31.9  feet
Top Speed, Side-to-side: 9.13  mph
Time to Side: 3.76  sec
Top Speed, Corner-to-Corner: 9.13  mph
Time to corner: 4.84  sec
This is significantly worse performance.   It could get better if we go to 2270 into 36×1 at 16V which is doubling the rated voltage of these motor.

Torque (per motor) to spin wheels: 20.2 oz-in
Amps (per motor) to spin wheels: 33.9 Amps
Theoretical Top Speed: 11.3 MPH
Total Peak Amps: 67.9 Amps
Amp Hours Required – 3 Min: 2.377 AH
Amp Hours Required – 5 Min: 3.962 AH
Weight Effective Pushing Force Top Speed
60 lbs 48 lbs 11.3 mph
Arena Size (feet)

Time to Top Speed: 2.98  sec
Distance to Top Speed: 32.7  feet
Top Speed, Side-to-side: 10.6  mph
Time to Side: 3.13  sec
Top Speed, Corner-to-Corner: 10.6  mph
Time to corner: 4.06  sec
We are pulling 33.9 Amps at 16V which is ~540 Watts.  These motors are rated to 190 watts so I worry about heating, even in a 3 minute match.

September 29, 2015

USB Relay with LabVIEW

Filed under: Daily — profmason @ 8:12 pm

The IC-Station USB 4 channel relay uses a serial protocol to communicate with any serial device.  The device appears as a virtual COM port and in controlled using 9600 8N1.

The protocol requires the following commands to be sent after initialization before any relays can be addressed.

  • HEX x50  (Should respond xAB)  This is the same as ASCII P
  • 20 ms pause
  • HEX x51  This is the same a ASCII Q

This initialization is so that noise on startup doesn’t toggle any of the relays.

Once the board is initialized, then the individual relays can be addressed by sending a single character of HEX code.   The last four bytes control the 4 relays on the board.

IE sending B00001111  turns all 4 relays on.  B00001111 = x0F

Sending B00000000 turns all relays off.

Testing the module is as simple as opening up putty or any other serial terminal and sending P then Q. This puts the module in receive mode.  Now send 0-O to set the different states of the module.  This works since the last 4 bits of 0-O correspond to the possible states in the 4 relay module.

The module uses a PL2303HX module which will require the latest version of the prolific USB-Serial driver and may not work on windows 8.  The module contains a small 8 bit ST micro and a ULN2303 transistor pack.  It is a shame that they didn’t write a bit more complicated firmware and pull the rest of the pins of the micro out as this could have been a really nice board without them spending any more money.

Here is some sample python code from the ic-station website, note the pyserial module must be installed and it assumes that your device enumerates as COM3:

import serial
import time

fd=serial.Serial("COM3",9600)
time.sleep(1)
fd.write('x50')
time.sleep(0.5)
fd.write('x51')

def relay_1():
fd.write('x00')
time.sleep(1)
fd.write('x01')
if __name__ == "__main__":
relay_1()

Here is the labview code: USBRelayTest

September 12, 2015

Multiplexing Pololu line sensors for use with VEX Cortex and RobotC

Filed under: Daily — profmason @ 4:15 pm

Pololu sells a variety of the line sensors that are ideally suited for following a 3/4″ line on a contrasting background.  These in the QTR-8 series and the Zumo series.  The QTR-8A sensor pictured at right has 8 IR sensors which will detect a white or black line at a distanced of between 1 and 2 cm from the surface.  These sensors  can be interfaced directly with the analog inputs on the VEX cortex.  However, since the QTR-8A has 8 sensors, it would require all 8 of the analog inputs on the cortex.  In addition, the Analog polling on the Cortex through robot C is slow.  Instead, we will use an Arduino Nano to read the 8 sensors on the QTR-8A and generate a single analog output that contains the position of the line in the sensor.

Image result for rc low pass filter calculator

Hardware assembly:

0. Build an RC filter.  A low pass RC filter will be used to smooth the pulse width modulated output from the arduino to generate a reasonable approximation of an Analog Output that can be read by the Cortex. To determine what values are appropriate you can calculate the roll off frequency of the filter according to f = 1/ (2pi * RC)  For this application you want a roll off frequency of around 1 MHz.

  • Solder your resistor to the ground pin on the Arduino Nano
  • Solder your cap with with one end connected to D3 and the other connected to the other end of the resistor you just soldered to ground.

1.  Solder the end of a male servo connect to the Arduino Nano as follows:

  • Red to 5V
  • Black to the junction of your resistor and capacitor from the RC step above
  • White to Digital 3

2. Solder 10 wires for a strip connector to A0 through A7 plus gnd and 5V.

3.  Solder the other end of the wires you just attached to the Arduino to the Pololu board connecting the

ground to ground, 5V to VCC and the analog inputs to the corresponding sensor output pins on the QTR-8 according to the picture at right.

Software:

Below is a program for the Arduino that reads the 8 analog sensors from the QTR-8A, calculate a weighted average, and then outputs an analog signal which contains the location of the black line.  If no black line is detected, the sensor outputs 0.

 

uint32_t sensor[8];  //Array for Sensor Values
uint32_t sumValues = 0;  //Sum of the Sensor Values
uint32_t color = 0;  //Will be used as a Color flag for black or white lines. Not Implemented
uint32_t valueOut = 0;  //Output value for Analog Output
void setup()
{
Serial.begin(9600);  //Initialize the Serial Output
pinMode(3, OUTPUT);  //Define Pin3 as low impedance suitable for analog Output
TCCR2A = 0b10100011;  //Setup Fast PWM on timer 2 to run at 56KHz
TCCR2B = 0b00000001;
OCR2B = 128;          //Set Pin3 to run at 50% duty cycle since 8bit.
}

void loop()
{
sensor[0] = analogRead(A0);  //Read in analog Values
sensor[1] = analogRead(A1);
sensor[2] = analogRead(A2);
sensor[3] = analogRead(A3);
sensor[4] = analogRead(A4);
sensor[5] = analogRead(A5);
sensor[6] = analogRead(A6);
sensor[7] = analogRead(A7);

valueOut = 0;  //Initialize the variables to calculate the weighted average
sumValues = 0;
for(int i = 0; i < 8; i++) //Loop through each of the Sensors
{
valueOut += sensor[i]*128*(i);  //Weight the Sensor Values
sumValues += sensor[i];         //Calculate the Sum of the Sensor Values
}
if(sumValues <= 400)  //This is the cut to throw away data if no line is detected.
{
valueOut = 0;
}
valueOut /= sumValues;  //Calculate the weighted average
//Serial.println(valueOut);  //For debugging
OCR2B = (valueOut/4)%256;    //Generate the Analog Output on Pin 3
delayMicroseconds(100);      //Wait a bit so things can settle
}
Older Posts »

Powered by WordPress