In car multigauge

What are you developing?
User avatar
BennehBoy
Posts: 236
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Postby BennehBoy » Sun Feb 12, 2017 4:23 pm

RogerClark wrote:And integer maths is a lot faster than floating point. So if I only need 2 or 3 decimal points of accuracy, I multiply the original input by 100 or 1000, and use integer maths (as long as the value will fit in an integer), then split out the integer and decimal point parts when I display the value.


Does anyone know whether something like matlab can output the integer equivalent of a floating point calc?

I tried for about an hour to convert these relatively simple calcs to use scaled integers and unceremoniously failed on all counts - I wasn't very studious during any of my mathematics education :D
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 5283
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: In car multigauge

Postby RogerClark » Sun Feb 12, 2017 9:33 pm

Its not essential to do interger maths, its just a lot faster on MCUs like the F103 that does not have a built in maths co processor.

You could always post your equations here, and see if anyone has any ideas

User avatar
BennehBoy
Posts: 236
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Postby BennehBoy » Wed Feb 15, 2017 8:20 pm

Does anyone have any examples of command/response queuing using FIFO's?

When I get above a few OBD requests per 250ms the simulator (and I assume real ECU's) begin to queue the commands internally and the responses come back asynchronously.

I think I need to issue commands based upon the speed that the data is likely to change, eg RPM I'd probably want to update every 250m/s but coolant temp could be a few seconds or longer interval.

I'll update my state machine to have a few different levels of data frequency requirements and then pop the requests in a queue.

I need to be able to issue the commands either batched up or on a regular interval, so it seems the best way to achieve this is to have a couple of FIFO's

Naturally I need to make sure the queue doesn't get overun.

One for outbound commands.

Another to store responses - this would be populated using a serial event. main code loop would then iterate over all the responses in the queue and process them.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 236
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: In car multigauge

Postby BennehBoy » Mon Feb 20, 2017 1:25 pm

So it looks as though the asynchronous responses from the ELM327 simulator are erroneous.

The data sheet for the 327 states that it will only perform synchronous processing, anything sent to it whilst it is processing the current command is ignored unless it contains a carriage return - in this scenario is aborts the current process.

I still want to decouple the response processing from the command calls - currently the command calls spin in a while loop until a response comes back. This can take anything up to 200ms. Clearly this is a waste of cpu cycles. So with this in mind a FIFO for the responses may be of use.

What I need to figure out is whether the core serial buffer will hold enough response from the ELM for me to go on to doing other work and only processing the serial responses via serial.event which I believe happens every main program loop. I guess that serial handling is interrupt driven so this ought to work (I've not checked the core source yet to ascertain the default buffer size).

I think given use of a buffer in my serial.event code, and reading in all characters, I should be able to check if the ELM command prompt has been issued.

Assuming it has a simple case statement can be used to check the response type and populate my array of sensors with the appropriate results. I can also set a flag 'ELM_AVAILABLE' or similar which can be used to prevent further commands being issued in my loop if it is false.

All of this will probably rely quite heavily on the main loop being optimised.
-------------------------------------
https://github.com/BennehBoy


Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests