I'm interested in "Cable Counter", i plan to manufacture the mechanical part and can do that in my workshop. Here's details :
Cable Diameter : 10 mm
Cable Length : 200 - 250 m
Drum Diameter : 300 mm
Drum Length : 400 - 500 mm
Encoder : 200 PPR (Incremental with A and B output)
I would like to have a serial output as below format :
XXX.X,YYY.Y
where XXX.X represents layback in meters from 000.0 to 999.9 followed by "," and YYY.Y represents speed/min from 000.0 to 999.9
The problem is, i do not know where to start from, can anyone please advise ?
One thing also important, the diameter of the drum gets smaller as you free up cable from winch system in each row, so a formulation giving linear change is needed. eg : Drum have 4 layers of cable and top layer has 350mm diameter where end layer has 305mm diameter.
You need to decide where and how you're going to display the output. If it's on a dedicated LCD connected to an Arduino, there are lots of sources for those and the ones that are marketted for use with an Arduino will come with examples showing how to display data on them.
I suspect you'll need some buttons for things like resetting the counters. Some display shields include some buttons.
You will need to measure the amount of wire that has been dispensed. I suggest that the best way to do that is probably with an idler wheel that the cable runs past. Depending on the accuracy you may be able to just count rotations e.g. with a magnet/reed switch, or you may need to use a rotary encoder to measure the rotation angle more accurately.
Thanks for your advise but as i wrote it clear "I would like to have a serial output ", there won't be any LCD, but it's to have it too in addition to serial output. A magnet switch or similar won't help since it cannot understand the direction of turn, that's why i think about Encoder with two outputs. Of course there will be two switches or one Toggle switch (On)-Off-(On); whereas first (On) turn cw drum, Off is idle drum and second (On) ccw drum.
Here's more explanation, an Encoder with 200 PPR will give 200 A and 200 B signals to Arduino in each turn, Arduino can understand which direction by rise-fall edges of A and B signals, then the formulation comes as (Drum Top Layer Diameter : 350mm) ; 2 x 3.14 x 0.175 = 1.099 meter. From scratch (0.00 meters if we start to turn drum 50 times (let say cw), the top layer ends and starts on middle layer, assume that the diameter of middle layer is 335mm, then still continue to turn the drum in same direction (cw) let say 20 times, then calculation as follows 50 x 1.099 = 54.95 + (20 x ( 2 x 3.14 x 0.167)) = 54.95 + (20 x 1.048) = 54.95 + 20.96 = 75.91, now there's 75.91 meters of cable out from drum. Let turn the drum let say 35 times but this time ccw, so the calculation as follows 75.91 - ((20 x (2 x 3.14 x 0.167)) + (15 x (2 x 3.14 x 0.175))) = 75.97 - (20.96 + 16.48) = 75.97 - 37.44 = 38.53, so there's 38.53 meters of cable out from drum. We seperated the 35 into 15 and 20 because there are two different layers with different diameter. The serial output should give 2 Hz output in layout cable amount along with speed/min, the speed/min can be measured by an optical swith or Encoder but it's the next step i believe.
Then we have to give some constants like :
Top Layer Diameter : 350 mm - 50 turn in layer [ Total Length = ( 50 x (2 x 3.14 x 0.175) ) = 50 x 1.099 = 54.95 meters ]
Second Layer Diameter : 335 mm - 50 turns in layer [ Total Length = ( 50 x (2 x 3.14 x 0.167) ) = 50 x 1.048 = 52.40 meters ]
Third Layer Diameter : 320 mm - 50 turns in layer [ Total Length = ( 50 x (2 x 3.14 x 0.160) ) = 50 x 1.004 = 50.20 meters ]
End Layer Diameter : 305 mm - 50 turns in layer [ Total Length = ( 50 x (2 x 3.14 x 0.152) ) = 50 x 0.954 = 47.70 meters ]
Of course, there should be one button to reset the output to zero.
Normally this kind of problem is solved by having a separate measuring wheel and thereby eliminating the problem of compensating for the varying drum diameter. This diameter can be hard to predict because of uneven coiling.
Uneven coiling may not be a problem by help of level wind, and due to enough stress on cable it will go just back in place when turning back. What else can be assuming a mean value for each turn. eg : mean value in respect to above example, calculation as follows ;
Mean Cable Layback in each turn = ((2 x 3.14 x 0.175) + (2 x 3.14 x 0.167) + (2 x 3.14 x 0.160) + (2 x 3.14 x 0.152)) / 4 = (1.099 + 1.048 + 1.004 + 0.954) / 4 = 4.105 / 4 = 1.026 meter / turn
Now, it becomes easier, each 200 signals will give 1.026 meter minus or plus to previous value depending on direction of drum rotation, this calculation should be done in 2 Hz (twice a second) independent from any amount, so the value will be repeated when the drum is in idle. Any ideas for software part ?
A couple of idler/pinch rollers on the cable seems so much simpler. Use a rotary encoder, if this is for a one-of project, you could use one taken out of an old ball mouse. If you have a lathe, or access to one, you could make the idler roller of a hard rubber wheel with a plastic wheel as a pinch roller. I'd flatten the hard rubber wheel, put the sensor on that, and turn the plastic wheel so it has a channel to keep the cable centered.
The Quadrature encoding will tell the Arduino which way it is rotating.
You didn't say that you need to be able to measure the cable travel in both directions - I assumed it was just a dispenser. If it needs to be reversible then instead of using a single reed switch you would need two of them to act as a crude encoder with a resolution of one rotation. If you need a finer resolution than that, you would use a real encoder which would give you a resolution down to one or two degrees.
It is not sensible to measure the rotation of the spool itself because the amount of cable dispensed per revolution is not predictable. Use a separate idler pulley that the cable runs over. This also means you don't need to modify or attach anything to the supply pulleys - you just pass the cable through your gauge as it is dispensed.
PeterH:
You didn't say that you need to be able to measure the cable travel in both directions - I assumed it was just a dispenser. If it needs to be reversible then instead of using a single reed switch you would need two of them to act as a crude encoder with a resolution of one rotation. If you need a finer resolution than that, you would use a real encoder which would give you a resolution down to one or two degrees.
It is not sensible to measure the rotation of the spool itself because the amount of cable dispensed per revolution is not predictable. Use a separate idler pulley that the cable runs over. This also means you don't need to modify or attach anything to the supply pulleys - you just pass the cable through your gauge as it is dispensed.
This is also considered, a dummy (of course load taking) pulley with known diameter so the dimensions are constant in each turn (let say one turn equals to 800 mm), so every cw gives +0.800m and every ccw gives -0.800m to previous value whatever in buffer. Do you know any closer example code for review ?
newbie_led:
Do you know any closer example code for review ?
Code to do what?
How you read the sensors will depend on what type of sensor you are going to use, but neither a rotary encoder nor a pair of reed switches would be difficult to read.
This probably won't work in your situation, but I thought I would mention it. It is a method that I saw being used by a phone repair guy. He wanted to determine where my phone line was broken.
He used his manual resistance meter, and watched the speed of the needle movement as he applied it to the two wires. He said that the two long wires running next to each other form a capacitor. Then, by watching the needle he can see how fast the meter charges the capacitor. Of course, by eye, he could tell me how many feet it was, but he could [edit, add "NOT"] tell if the break was local, or at the switch, which was a half mile away.
A rotary electrical connection is so noisy that it would be useless for this. So it would only work if you stopped to measure the length, and clamped onto it electrically. It probably would not be accurate enough either.
But, for your own project, you might not be aware of this, but devices that measure cable length are common in industry. However, I have only seen ones with mechanical counters. But, hacking into that is probably easier than making your mechanics from scratch.
There are electronic bicycle computers that will give you total distance. You have to enter your wheel diameter first, but I don't now how small they can go. An alternative is the kind of device that you roll on the ground to measure distance. I have seen ones with smaller wheels, and that may be perfect for your application.
first concern is resetting when drum is full, this should be done with a separate sensor.
for the rest your calcs look oke.
with 200 ppr you will have 800 positions per rotation, which is very good.
pulse is cw when A is on and B gets on (meaning it was not on last scan)
pulse is cw when A gets off and B is on
pulse is cw when A is off and B gets off
pulse is cw when A gets off and Bis off (see other comment)
make yourself the ccw.
while unwinding each puls is 1.099/800 meter for first 50800 pulses
assume position is 4000 the cable is out for 501.099 meter.
assume position is 50000 the cable is out for calclength=400001.099/80050 +100001.048/80050
etc
speed
newtime is millis()
if newtime -oldtime > 1000
{
oldtime=newtime
speed= calclength-oldlength
oldlength = calclength from above
}
newbie_led:
@ cadcoke5, I really wonder how you bring the subject into analog readings by multimeter.
I imagine its best use would be to measure the amount of cable on a spool. You would do the measurement by applying 5 volts to one end of the cable, and also to an analog input pin. Then, you would measure how long it took for that voltage to actually rise to 5 volts. I suspect you should put a resistor in series at the 5 volt out, to guarantee it didn't exceed the current limits for the output pin.
Since the capacitance, and wire resistance for any particular cable would vary from one type of cable to another, you would have to calibrate it against a known cable length, and extrapolate the values to determine how much is on the unknown spool. Off the top of my head, I don't know if the values for cable length are linear.
But, all of the above is useless for the original posters needs. We now know that he just needs to measure how much he is pulling off of a spool. I really suspect the roll-on-floor measure device is the best choice. No Arduino needed for that. Here is what I am talking about, if you are not familiar with them. $30 Measure Wheel. http://www.homedepot.com/p/Johnson-3-ft-Compact-Measuring-Wheel-JL0100/202911640#.UngOMOL5Mus
newbie_led:
@ PeterH,
All example codes was about fade in-out LEDs and PID related ones about Encoder usage. The case for code :
Digital Input 1 : Encoder A
Digital Input 2 : Encoder B
Digital Input 3 : Reset
No Output
TX values in meters @ 2 Hz
The basic code to determine when the encoder has moved will be the same, though. Essentially you will be looking for the inputs to change state. Each time one input changes state, you look at the state of the other input to determine which direction the movement was. So now you know that the encoder has moved one step in a given direction - obviously at that point you would increment or decrement a counter and perform any action that you wanted to happen when the counter changed.
With code below, i'm able to measure the cable length passing through a pulley with diameter 0.3m, and code works flawless !!! Then second step, speed of cable in "meters/minute" or "meters/second", any ideas ?
// Cable Counter TX RS232 (2 Hz @ 9600)
int encoderPin1 = 2;
int encoderPin2 = 3;
volatile int lastEncoded = 0;
volatile long encoderValue = 0;
long lastencoderValue = 0;
int lastMSB = 0;
int lastLSB = 0;
void setup() {
// 9600 Bps
Serial.begin (9600);
pinMode(encoderPin1, INPUT);
pinMode(encoderPin2, INPUT);
digitalWrite(encoderPin1, HIGH);
digitalWrite(encoderPin2, HIGH);
attachInterrupt(0, updateEncoder, CHANGE);
attachInterrupt(1, updateEncoder, CHANGE);
}
void loop(){
Serial.print ("Cable Meter = ");
Serial.println (encoderValue*(0.94247/800), 1); // Setup for 200PPR Encoder attached to center of Wheel with 0.3m Diameter)
delay(500); //500ms (2 Hz)
}
void updateEncoder(){
int MSB = digitalRead(encoderPin1);
int LSB = digitalRead(encoderPin2);
int encoded = (MSB << 1) |LSB;
int sum = (lastEncoded << 2) | encoded;
if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --;
lastEncoded = encoded; //store this value for next time
}