Arduino uno stepper rev meter issue

Open a thread for a question about the simulator control software.
If you cannot receive any data in the input setup use the upper two forums!

Arduino uno stepper rev meter issue

Postby antenna » Sat 30. Jun 2012, 16:06

Hi to all.
I'm a new italian user, so sorry for my english. I've found this great forum searching for build a simple rpm meter for my sim, and after viewing other user post i realize my first project. The platform is an arduino uno connected to an h bridge to drive a small stepper motor from real car cluster( a clone of switec x25). I,'m using x-sim 3. The bound rate is setting to 115200 , x-sim sending data at 8 bit, decimal output. If i start the simulator the meter moves accordly but with some issue, is slow to reach the high point of the scale and sometimes instead of return to min, hold a * position. I try to change the pause in converter from 33ms to 40ms and slower but seems only affected the accuracy of the movement, if set to lower value instead the motor jitter or not moving at all.
I've tried the example sketch motor knob and other and the stepper works properly.
I think the problem is that arduino analog.read function is too slow to reading the data coming from x-sim as decimal output. Maybe if i send it in binary form the aquisition could be faster but i need a help for the code. I post the currently used.
Thanks in advance.
Code: Select all
#include <Stepper.h>


Stepper stepper(720, 2, 3, 4, 5);


int rpm;
int nextStep;
int pos = 0;


char kind_of_data;


void setup(){
 
Serial.begin(115200);
 
stepper.setSpeed(30);


}


void loop()
{
 
while(Serial.available() > 0)
{

    kind_of_data = Serial.read();
    if (kind_of_data == 'R' ) Read_rpm();
   
   
}

}
void Read_rpm(){
  delay(1);
  int rpm100 = Serial.read()- '0';
  delay(1);
  int rpm10 = Serial.read()- '0';
  delay(1);
  int rpm1 = Serial.read()- '0';

  rpm = 100*rpm100 + 10*rpm10 + rpm1;
  rpm = map(rpm,127,255,0,600);
 
  nextStep = rpm - pos;
  stepper.step(nextStep);
  pos = rpm;
}
antenna
 
Posts: 5
Images: 0
Joined: Sat 2. Jun 2012, 18:57
Has thanked: 0 time
Been thanked: 0 time

Re: Arduino uno stepper rev meter issue

Postby sirnoname » Sun 1. Jul 2012, 00:22

Hello antenna,

this what you did is of course possible but not the right way.
Enter in the OBD2 interface list your arduino comport and send 010c.
You will get back the RPM as described here:
http://en.wikipedia.org/wiki/OBD-II_PIDs

So you do not need to start a converter and you can get compatible to OBD2 interfaces of real cars (need a ELM setup string described in the ELM327 IC documents)

This will solve the speed problem because you trigger the question and then get a response.
The bad thing is that only speed, RPM, gear and colant are available for *
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino uno stepper rev meter issue

Postby antenna » Sun 1. Jul 2012, 16:23

Hi SirNoName, thanks to reply.
I'm trying to follow your suggestion but with no luck. I'm getting in trouble to find schematics or info for the connection my dashboard uses.
The dashboard coming from an european car Renault Clio year 2000 i think. In the rear of the board there are two sockect a grey 32 pin and a red 15 pin, i discovered that are a sagem nec hc08 connector,
but i dont know if is are obd2 compliant, and if i need additional hardware to connect them up.
Maybe someone can guide me in the right direction.
Thanks again.
antenna
 
Posts: 5
Images: 0
Joined: Sat 2. Jun 2012, 18:57
Has thanked: 0 time
Been thanked: 0 time

Re: Arduino uno stepper rev meter issue

Postby sirnoname » Sun 1. Jul 2012, 16:50

You have to connect your arduino to a comport, not the dashboard!
Then you have to reprogram your above code for the request.
Do you have written the above code?
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino uno stepper rev meter issue

Postby antenna » Sun 1. Jul 2012, 20:37

I've haven't tried yet, iknow to connect arduino on comport(already on com 3) not dashboard, but what i can't figure out
is how to put all togheter. I imagine a chain like this. pc(x-sim)>arduino(com3)>ELM327 AT > something missing>dashboard.
I think i need some stuff or schematic to wire elm327 with the board chip or am i wrong?
antenna
 
Posts: 5
Images: 0
Joined: Sat 2. Jun 2012, 18:57
Has thanked: 0 time
Been thanked: 0 time

Re: Arduino uno stepper rev meter issue

Postby sirnoname » Sun 1. Jul 2012, 20:46

Yes wrong ;)
Much simpler.
The x-sim software is the virtual ELM327 chip.
Your arduino must only use this chip.
You can download the ELM327 datasheet and talk to the x-sim3 OBD2 interface like you do with with your arduino to a real ELM327 chip over RS232.
Simple test it with a PC.
Connect it to the extractor OBD2 comport and send in the hyperterminal 010c.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times


Return to Converter questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron