Show Posts
|
|
Pages: 1 [2] 3
|
|
16
|
Using Arduino / General Electronics / Re: LM2917 tachometer calculation help..
|
on: September 14, 2011, 01:06:06 pm
|
Sorry I got confused with single-coil dual-winding/two cylinder bike engines, they fire on exhaust stroke. The Royal Enfield is a 4-stroke some models with dual-sparkplug, so I figure 2 revs/spark. 2000RPM/60=33.3Hz crankshaft speed/2 = 16.67Hz ignition frequency. At 800RPM =6.67 Hz, at 8,000 RPM = 133.3Hz At 800RPM =150msec, at 8,000 RPM = 15msec between pulses I would use a timer on the Arduino to measure time between ignition pulses and convert to RPM. You are using the LM2917 to drive an analog meter? See page 10 on app. note http://www.national.com/an/AN/AN-162.pdfalso thread here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237171773A capacitive ignition sensor can be made with a couple turns of wire wrapped around the spark-plug wire and then into the 555 circuit. I have never found a source for inductive pickups. You can make one with a split ferrite core (like EMI snap-on cores).
|
|
|
|
|
18
|
Using Arduino / Sensors / Re: Challenging gearwheel sensor problem
|
on: September 14, 2011, 10:58:27 am
|
|
I think you have two things to sense. When the lenses are at (either) end of travel, you need 3 or 6 (home) limit-switches also. VCR's use a small hole drilled in the gear with opto-sensor, or microswitches and a cam lobe to find home.
Next, to measure position- a slotted (quadrature) optical encoder wheel, from an old computer mouse, old DSLR lens or plastic cutout from laser print out. A hall-sensor on the motor might work but I have not tried. The gear teeth themselves are really small and aligning the sensor would be difficult.
What I have done is used ~1" plastic tubing to connect a rotary encoder to the mech. shaft. The tubing allows misalignment and stretches snug on the shafts, or use glue/clamps but it's low torque.
|
|
|
|
|
20
|
Using Arduino / General Electronics / Re: LM2917 tachometer calculation help..
|
on: September 13, 2011, 09:01:41 pm
|
 if your bike is a 4-stroke engine, you get a spark every 4 engine revolutions. If your bike is a 2-stroke engine, you get a spark every 2 engine revolutions. 2000RPM/60=33.3Hz crankshaft speed = 8.33Hz (4 stroke) or 16.67Hz (2 stroke) ignition frequency.
|
|
|
|
|
21
|
Using Arduino / General Electronics / Re: Using tranistors on PWM outputs
|
on: September 13, 2011, 08:55:08 pm
|
|
Wait - do you have the pinout correct on the BC546 C-B-E? It looks like your excess current is not the LED's staying on, but the Arduino outputs staying high during sleep mode and driving the transistors? First you need a base drive resistor a few kohms, never direct. Second you can drive the pins low, or pinMode them to inputs before you go to sleep, to save power.
|
|
|
|
|
22
|
Using Arduino / Programming Questions / Re: Strange behaviour from Arduino with I2C
|
on: September 13, 2011, 08:40:17 pm
|
|
I've been assigning SPI pins CS,MISO,SCK,MOSI as input/output pins with pinMode(), and enabling pullup resistors on CS and MISO in Setup(). With a scope, I noticed these pins can float and cause weirdness. Check it by touching them with your finger and seeing if things change. I'm not sure what the MAX6675 library does for SPI setup, but it's good for 4.3MHz SPI which seems fast enough.
|
|
|
|
|
23
|
Using Arduino / Programming Questions / Re: How to convert a long into float?
|
on: September 12, 2011, 05:28:38 pm
|
The LTC2418 24-bit A/D is a real bear to get working ]  The conversion data and channel numbering are from Mars. Its output data is "somewhat" 2's complement- there are status bits to tell -ve or +ve over range and I finally have a signed long for the conversion (I will post my sketch in another thread once I get it finished). I need a float to print voltage. //This code works fine, I get a float with the static(?) cast:
signed long adc_value;
adc_value=getAtoD(); adc_result= (float) adc_value; adc_result= /838860.8; // R divider 9V max; A/D=2.5Vfsd Serial.println(adc_result,4);
However, I went to using a union to store the A/D data and it doesn't work properly: union { float v_modem; // Ch. 4 scaled voltage 0-5V float v_solar; // Ch. 3 scaled voltage 0-5V float modem_vreg; // Ch. 2 scaled voltage modem vreg 0-9V float I_monitor; // Ch. 1 scaled current 0-2A float v_board; // Ch. 0 scaled voltage 0-9V } adc; //--------------------------------------
void mysub() {
signed long adc_value;
adc.v_board = 0.0; adc.I_monitor = 0.0; adc.modem_vreg = 0.0; adc.v_solar = 0.0; adc.v_modem = 0.0;
adc_value=getAtoD(); adc.v_board = (float)adc_value/838860.8;
Serial.println(adc.v_board,4); Serial.println(adc.I_monitor,4); Serial.println(adc.modem_vreg,4); Serial.println(adc.V_solar,4); Serial.println(adc.V_modem,4); } V_board is correct i.e. 6.0512V but ALL channels in the union have the same value 6.0512V 
|
|
|
|
|
24
|
Using Arduino / Installation & Troubleshooting / Re: Loading code to Arduino through USB in Windows 7
|
on: September 07, 2011, 06:43:02 pm
|
|
I found my USB hub made things not work properly- connect directly to your PC. Then uninstalling the USB driver then reinstalling in Windows7 fixed things. I go to Computer->Manage->Device Manager and see if connecting/disconnecting the Arduino shows COM port assignment. COM1 can be your motherboard RS-232, not a USB assignment.
I had some hassles with the Mega2560 under Windows7. It does not use the FTDI USB chip, instead uses Atmel 8U2 so I had to load the USB driver from drivers\Arduino MEGA 2560.inf ... but not so with the Mega328.
|
|
|
|
|
25
|
Using Arduino / Programming Questions / How to convert a long into float?
|
on: September 07, 2011, 01:18:02 pm
|
|
I have a 24-bit signed quantity (from A/D converter LTC2418) and need to convert it to a float (voltage). I'm finding this really hard and not sure where things go wrong. I get the 24-bit A/D data and sign-extend into a 32-bit long:
signed long adc_value;
adc_value=getAtoD(); Serial.println(adc_value,HEX);
adc_result= (float)adc_value; Serial.println(adc_result,2);
Results A/D data: 0xC0000000 (+2.5V fullscale) sign extends to -> 0xFFC00000 gives-> -4194304.00 (expect 838608.00) 0x80000000 (zero) sign extends to -> 0xFF800000 gives-> -8388608.00 (expect 0) 0x7FFFFFFF (-1 LSB) sign extends to -> 0x007FFFFF gives-> 8388608.00 (expect -1.00) 0x40000000 (-2.5V fullscale) sign extends to -> 0x00400000 gives-> 4194304.00 (expect -838607.00)
I can't understand why the values are off.
|
|
|
|
|
27
|
Using Arduino / Programming Questions / Re: How to convert 4 bytes into a long? (SOLVED)
|
on: September 02, 2011, 06:50:35 pm
|
|
byte d[4]; long adc_value;
<.... stuff deleted>
adc_value = (long)d[0] << 24; adc_value += (long)d[1] << 16; adc_value += (long)d[2] << 8; adc_value += (long)d[3];
This code works fine now. (Without proper casting to a long, I get swapped nibbles i.e. 21346587) Thanks to everyone, esp. jraskell for the help.
|
|
|
|
|
30
|
Using Arduino / Programming Questions / Re: How to convert 4 bytes into a long?
|
on: September 01, 2011, 11:17:14 am
|
|
I do get interesting results and am still looking for a solution. It looks like the shift operator is only 16 bit. The cast to a long swaps nibbles on some of the bytes, which is strange. Thanks everyone for your help so far.
byte d[4]; long adc_value;
d[0]=0x87; d[1]=0x65; d[2]=0x43; d[3]=0x21;
adc_value=0; adc_value += d[0] << 24; adc_value += d[1] << 16; adc_value += d[2] << 8; adc_value += d[3]; Serial.println(adc_value,HEX); //--> prints 4321 (expected 87654321)
adc_value = *((long *)d); Serial.println(adc_value,HEX); // --> prints 21346587 (expected 21436587)
d[0]=0x12; d[1]=0x34; d[2]=0x56; d[3]=0x78;
adc_value=0; adc_value += d[0] << 24; adc_value += d[1] << 16; adc_value += d[2] << 8; adc_value += d[3]; Serial.println(adc_value,HEX); //--> prints 5678 (expected 12345678)
adc_value = *((long *)d); Serial.println(adc_value,HEX); // --> prints 78563412 (expected 87654321)
|
|
|
|
|