Pages: [1]
Author Topic: EDC15 Map switching another way to show selected map  (Read 3389 times)
barex
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


« on: November 05, 2022, 12:40:33 PM »

Hi
After weeks of trying i have finally working multimap in my daily car Cheesy
Big thanks to nihalot who share his knowledge how to do it in this topic
http://nefariousmotorsports.com/forum/index.php?topic=12637.0


But I also have an old off-road car with a swaped 1.9tdi engine. I would like to use this modification there, but the dashboard is analog. So I thought to display the selected engine map using the glow plug control light(pin 40 in 012 ECU) One blink the first map, etc.

I figured out which pin of cpu control glow plug control light, its 51pin named  P2.4
when i add
Code:
bclr P2.4

to the code the light is on. But how to blink this light without messing up rest of the program?
Using "delay" it is a bad idea?
Maybe someone did something like this and would like to share information about where to start and what to look for?
I am completely new to the world of assembler and processors so any information will be valuable.
Logged
terminator
Sr. Member
****

Karma: +15/-4
Offline Offline

Posts: 425


« Reply #1 on: November 05, 2022, 03:27:08 PM »

I believe there should be a routine that controls the glow plug lamp and it will do everything. All you need is to find it and pass some values (I think one of them is a mode(blinking, lighting etc)).
Similiar way you can deactivate it.
Logged
barex
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


« Reply #2 on: November 05, 2022, 04:45:50 PM »

You may be right, the glow plug indicator light starts flashing on some DTCs stored in memory. Just how to find this routine? I tried to look for the value of P2.4 in IDA pro but unfortunately I did not find it. Scrolling through the code, I noticed P2_4 values. Is P2.4 = P2_4? I guess it makes sense. Tomorrow I will search the code again. Maybe I can find something useful.
Or maybe there is a better way to find this?
Sorry for this noob questions but a few months ago I was afraid to open ecu so everything is new to me  Grin Grin
Logged
terminator
Sr. Member
****

Karma: +15/-4
Offline Offline

Posts: 425


« Reply #3 on: November 05, 2022, 05:40:55 PM »

I would search for a variable (not port).
something like:
bset var.1 or bclr var.1

P.S. I disassembled C166 a long time ago so I don't remember much.
Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #4 on: November 06, 2022, 06:08:00 AM »

The ECU runs an RTOS.
Almost every subroutine apart from the initialization runs in a task.
Tasks are scheduled to run in a certain raster. So fixed time (except some tasks that run crank-sync).

Add a counter, increment this counter every iteration, if MSB is set, turn it on, if MSB is not set turn it off.
Now you have blinking light.
If it's too slow/too fast, adjust.

For counter find free RAM.
Think about it like this:

uint8_t ctr = 0;
void 20ms_raster_task() {
   if (ctr > 0x80) {
      bclr P2.4
   }  else {
      bset P2.4
   }
   ctr++;
}

With this example the light is on for 2.56 seconds and after that off for 2.56 seconds, because 256 iterations of 20ms raster take 5.12 seconds to execute.
« Last Edit: November 06, 2022, 06:19:26 AM by prj » Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #5 on: November 06, 2022, 02:06:49 PM »

The ECU runs an RTOS.
Almost every subroutine apart from the initialization runs in a task.
Tasks are scheduled to run in a certain raster. So fixed time (except some tasks that run crank-sync).

Add a counter, increment this counter every iteration, if MSB is set, turn it on, if MSB is not set turn it off.
Now you have blinking light.
If it's too slow/too fast, adjust.

For counter find free RAM.
Think about it like this:

uint8_t ctr = 0;
void 20ms_raster_task() {
   if (ctr > 0x80) {
      bclr P2.4
   }  else {
      bset P2.4
   }
   ctr++;
}

With this example the light is on for 2.56 seconds and after that off for 2.56 seconds, because 256 iterations of 20ms raster take 5.12 seconds to execute.

Thats too slow and for adjusting delay ctr reset should be added instead of overflowing byte
You also want to zeros ctr when flashing done or the next time event starts at a random phase

Code:
uint_8t count // num of flashes
uint_8t delay // delay between flashes counter


if (count == 0xFF) {count = 0;} // iirc in me7 its 0xFF in non-used ram, so in code init should be done

if (count > 0) // from switching routine >> (if (new_map != old_map) { count = new_map; old_map=new_map;}  // new_map represents the value of current mapSet in range of 1-5 for example. fires once after map changed.

{
  if (delay < ??) { bset b_mil; }
  else {  bclr b_mil; }
  delay++;
 }
 if (delay > (??*2)) // 2.54 is a huge delay so zeros instead of overflowing  :-\
 {
  delay=0;
  count -=1; // eof blink
  }
}
else
{ delay = 0; } // reset timer after all blinks completed

OR

in me7 there is a B_milblk which blinks at 1hz freq and i suppose its a 1000ms / 20ms = 50 ticks on every phase and 100 ticks for complete cycle

so it could be simplified like that. notice about delay is a word now

Code:
uint16_t delay_w

if (delay_w >1) // from switching routine >> if (new_map != old_map) { delay_w = new_map * 100;  old_map=new_map;}
{
  bset B_milblk;
  delay_w -=1 ;
}
if ((delay_w == 1) or (delay_w == 0xFFFF))  // do not use 'else' to avoid conflict with a stock B_milblk routine when delay=0
{
 bclr B_milblk;
 delay_w = 0;
}


 
« Last Edit: November 06, 2022, 02:42:12 PM by fukenbroken » Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #6 on: November 07, 2022, 01:22:27 AM »

Thats too slow and for adjusting delay ctr reset should be added instead of overflowing byte
You also want to zeros ctr when flashing done or the next time event starts at a random phase
It was a bare minimum example for the concept, not finished code.
Because OP asked how to do delay, and clearly was not familiar with the RTOS.
Obviously if you want to adjust frequency and you want number of flashes you are going to have to implement something.

Did you just really try to "teach" me how to code?  Grin Grin Grin
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
fknbrkn
Hero Member
*****

Karma: +185/-23
Offline Offline

Posts: 1454


mk4 1.8T AUM


« Reply #7 on: November 07, 2022, 04:27:42 AM »

It was a bare minimum example for the concept, not finished code.
Because OP asked how to do delay, and clearly was not familiar with the RTOS.
Obviously if you want to adjust frequency and you want number of flashes you are going to have to implement something.

Did you just really try to "teach" me how to code?  Grin Grin Grin

Thats obviously not for you )
But for op and those who came with the same questions, just more complex pseudocode
Logged
barex
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


« Reply #8 on: November 07, 2022, 03:47:37 PM »

fukenbroken and prj you are geniuses Cheesy
I was able to write an assembly language program according to your idea and it works Cheesy
Unfortunately, I have one problem, when I use the bclr P2.4 function, the glow plug indicator does not light up at full power. It is slightly tinted.
Do you have any idea what it might be caused and how to improve it?

Even when I use the code written by nihalot in his tutorial and add bclr P2.4 to it, the glow plug indicator does not light up at full power. So I guess the code I wrote doesn't affect that.

Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #9 on: November 08, 2022, 12:34:28 AM »

Chances are that it's getting cleared immediately after in the normal code.
Find where the normal code is and make a condition, that when your logic is active, it should skip the clearing.

Or implement the OEM blinking, chances are if you use the OEM blinking solution then it will already skip clearing.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.032 seconds with 17 queries. (Pretty URLs adds 0s, 0q)