s2000 cluster project

Kschwiggy

New Member
got my speedo code tweaked... here it is for sharing. the processor is 16f877 and coding is done in PICBasic Pro

Define LOADER_USED 1
define osc 4
define hpwm2_tmr 1
define ccp1_reg portc
define ccp1_bit 3
f var word
sf var word
TRISB = 0
TRISC = %01000000 ;C2 output
Cycle:
count PORTC.1,125,F ;count pulses for 1/8 second
sf = f * 312 ; f * 39* 8
case select sf
case is <=244 then hpwm 0, 127, sf
case is >= 245 then hpwm 1, 127, sf
end select
goto Cycle

with the ECT code from orthello .... i dont know why but my cluster is just showing full bars constantly. im working on that now. orthello - did u use different PICs for vss and ect? right now i'm trying to run both ECT and VSS on the same 16f877 and maybe theyre conflicting
 

defensio

New Member
i already have many pic16f88 chip
do you think this code work ?

orthello: i have many docs abour AVR and PWM but its hard to mix ADC and PWM.

but at this time im probably try to go with PIC. and i will make my own atmega16 in the futur!
 

orthello

The Dutch Guy
i need some help to match my ODO to my s2k cluster.

i read the chip and make back up.

but i dont really know how to make the change in bin file...

its possible to have more explain?


S2k Can EEPROM code,



my cluster have 54352km in HEX its D450, but if i change in the bin file where its write D4 50, it didnt work.
Actualy it's a bit different.

The ODO is stored at the very end of the memory, the last 4 lines (00C0 to 00FF).
In this case it is:
Code:
06 AC F9 53 06 AC F9 53 06 AC F9 53 06 AC F9 53
06 AC F9 53 06 AC F9 53 06 AC F9 53 06 AC F9 53
06 AC F9 58 06 AC F9 58 06 AC F9 58 06 AC F9 58
06 AC F9 58 06 AC F9 58 06 AC F9 58 06 AC F9 58
Note that 53 changes in 58 in the last two lines.

The calculator that is posted earlier in this thread only generates the first 4 bytes.
So in this case that would be: 06 AC F9 53.
This should be written in the eeprom like this:
Code:
06 AC F9 53 06 AC F9 53 06 AC F9 53 06 AC F9 53
06 AC F9 53 06 AC F9 53 06 AC F9 53 06 AC F9 53
06 AC F9 53 06 AC F9 58 06 AC F9 53 06 AC F9 58
06 AC F9 53 06 AC F9 58 06 AC F9 53 06 AC F9 58
So.. repeat the 4 generates bytes 16 times. The ODO will not EXACTLY show what you want, but will always be within a reasonable range of what you want. If you put a little less on the ODO meter via reprogramming the eeprom, you can always take care of the last part by using a pulse generator.
 

defensio

New Member
i have made this few weeks ago, its work perfectly =)

do you know about if pic16f88 is compatible with code write in pic16f877?

edit: i think yess cause the 87 and 88 datasheet look like the same, the 88 have a A/D 10 bit channel. 87 didnt have.

Kschwiggy:
for more easy built up, please post a electrical diagram of your converter!

its nice to make it all open source.
 


Last edited:

orthello

The Dutch Guy
16F877 is one big ass processor for this purpose.

I have split the converter in two pices.
16F628A for VSS
12F675 for ECT

This two small processors together are 1/4 the price of one 16F877(a)
Not mentioning the different size in hardware.

16F628A is 16 pins
12F675 is 8 pins

While the 16F877(a) has 40 pins ;)

16F628A has a PWM module and a timer onboard which can be used to measure and produce the signal for the VSS.
12F675 has a 10bits ADC (1024 steps from 0 to 5 volt) onboard to read the ECT voltage.

Both can run without extrernal clock. So less parts. The internal clock is less accurate then an external one, but accurate enough for our purpose, as VSS signals are very slow.

I have developed both converters with a 16F877(a) first because that is my development platform. Afterwards a changed the code a bit to fit it to the 16F628A and the 12F675

I developed ECT and VSS separeted from the beginning.
Having both in one processor got way to complicated and time consumming.
 
Last edited:

defensio

New Member
its my error. i have check for 16f87 and not 16f877.

orthello: im very interesting to make the same converter of you.

if you have new wiring diagram code etc i want to look at this =) cause the CRX going out soon =) and i really want to run with my S2k cluster =)

defensio@hotmail.com if you have some info to email me.

or post it on this forum =)

did you use:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=PIC16F628A-I/P-ND

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=PIC12F675-I/P-ND

???
 
Last edited:

orthello

The Dutch Guy
Yep..

These are the two controlers to use. Correctly.

I'll drop my lines of code.
Schematics will be available soon.



VSS
Code:
Device 16F628A
Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_ON
'B0 = VSS input signal = input  (pin 6)
'B3 = VSS output signal = output (pin 9)

Dim tm As Word
Dim ttm As DWord
Dim Fout As Word
Dim ovf As Word

tm = 0                               ; set counter to 0
ttm = 0
Fout = 0                             ; output frequency -  245Hz is lowest possible
ovf = 0
         ;76543210
PORTB  = %00000000                  ; all low
TRISB  = %00000001                  ; 7, 6, 5, 4, 3, 2, 1 en 0 are input (1) or output (0)
INTCON = %11010000                  ; Enable interrupts  (GIE, PIE, RB0)
T1CON  = %00110000                  ; setup timer1 with 1:8 prescale (1:2 and 1:4)
PIE1.0 = 1                          ; enable tmr1 interrupt

on_interrupt GoTo interrupt_handler

    While 1=1

    Wend

interrupt_handler: 
 If INTCON.1 = 1 Then                 ; VSS pulse came in
    T1CON.0 = 0                       ; stop counter
    tm.LowByte  = TMR1L               ; read and save counter
    tm.HighByte = TMR1H
    TMR1H = 0                         ; reset counter to 0
    TMR1L = 0
    T1CON.0 = 1                       ; (re)start counter
    ttm = tm + (ovf * 65535)
    ovf = 0
    If ttm > 0 Then 
  ;     Fout = 39000000 /(ttm * 8)      ; Fout[p/s] = (multiplier / divider[at output]) * 1000000 [us/s] / (cc [p] * 8[p/us])
       Fout = 39000000 /(ttm * 2)      ; Fout[p/s] = (multiplier / divider[at output]) * 1000000 [us/s] / (cc [p] * 8[p/us])   [with 4 multiplier at output]
       If Fout > 245 Then HPWM 1, 127, Fout   
    EndIf
  EndIf  
  
If PIR1.0 = 1 Then                   ;timer1 interrupt
    If ovf < 2 Then                  ;Because the timer counts a bit fast (thus accurate) we also need to count the overflows
       ovf = ovf + 1
    Else
        T1CON.0 = 0                      ;stop counter as the car has stopped (no input VSS pulse within 1,5 seconds)
        TMR1H = 0 
        TMR1L = 0
        Fout  = 0
        ovf =0;
        T2CON=%0000000 ; stop hpwm
    EndIf
    PIR1.0 = 0                          ; reset timer interupt flag
 EndIf
     INTCON = %11010000 ; Reset all interrupt flags
Return


ECT (not fully tested yet with this controler. Config commands are missing)
Code:
Device 12F675
Config INTRC_OSC_NOCLKOUT, WDT_OFF, MCLRE_ON
'AN3 = ECT input signal = input  (pin 3)
'GP5 = ECT output signal = output (pin 2)

TRISIO = %00011111 'all ports inputs
ANSEL = %00001000 'AN3 (GP4) is analog input
CMCON = %00000111 'Shut down the comparator
ADCON0 = %10000000 'right justify the A/D result
 
Dim adc As Word
Dim temp As Word
Dim i As Word
Dim ht As Word
Dim lt As Word

adc = 0
temp = 0
i = 0
ht = 30     ; high level is always 30ms
lt = 0


GPIO.5 = 0

DEFINE  ADC_BITS        10 
DEFINE  ADC_CLOCK       0   
DEFINE  ADC_SAMPLEUS    10        
While 1=1

    adc = ADIn 3                  ; Read channel AN3  
;    adc = adc / 2                 ; To have a full scale reading during tests. 

    For i = 0 To 6
          ; in celsius:         [ 113,  104,  96,  88,  79,   71, cold]
        temp = LookUpL   i,     [  71,   87, 106, 131, 161,  200, 1024]
        If adc > temp Then
           i=i
        Else 
          ; in bars/segments:  [   7,    6,   5,   4,   3,    2,    1]     
            lt   = LookUpL i,   [ 150,  220, 300, 400, 700, 1100, 1500]
           i = 7
        EndIf
    Next
    
    GPIO.5 = 1
    DelayMS ht
    GPIO.5 = 0
    DelayMS lt
Wend
End
 


Last edited:

defensio

New Member
:D really thanks,

i will have my microchip next week =) i hope to test it =)

in my "beautyfull" civic 90 4 dr (winter car):twisted:
 

plummo_vtec

New Member
Fantastic progress! This is a very exciting time we are close to all been able to have these conversions in our cars, i for one cant wait, keep up the great work guys
 
Last edited:

orthello

The Dutch Guy
I'll publish the VSS schematics today.

ECT needs to wait, as I haven't tested that one in the final version yet.
 
Last edited:

acclude

cheap bastard
Great progress! This is not an easy task so mad props to all of you making it work! I dug into something a while ago trying to make a boost controller using PWM but it got so complicated that I just dropped the project :( There was already other options available so I just went that route. This on the other hand is a quite amazing. Great job guys!
 

orthello

The Dutch Guy
Tnx Acclude.

BTW.... I received some questions about the noise filter for the VSS sensor. The old reed type VSS sensor are very VERY noisy. This is mainly causted by the bouncing of the reed switch.
What did I do to solve this:


First I used a pull up resistor to have nice 5V to GND levels. The old reed type VSS sensors connects to ground, so this way you have a very nice 5V to GND level square type signal.... with lots of noise. Bounce noise of the reed switch to be more precise. So what I did...
I introduced a SmithTrigger. This is a digital swich with hysteresis (different switch levels for raising and falling edges). A lot of bounce was filtered out this way, but it wasn't perfect. As high noise passed the hysteresis threshold, still causing strange readings from time to time.
Now what to do with the high noise....
I created a debounce circuit by using 2 resistors and a capacitor.
I calculated the maximum pulse frequency to be expected from the VSS (@ 300km/h)
I calculated how fast the capacator had to charge and discharge and which resistors and capacitor are to be used to meet this time frame. [quick enough to fully (dis)charge before the next VSS EDGE!! is received but slow enough to cover all the bounce of the switch]
This way you lose the bounce noise of the switch, but you introduce 'slow' transistions from high to low level signals.
But, the slow transistions aren't a problem, as the SchmittTrigger creates very nice and steap edges.


Writing this, I'm thinking that the SchmittTrigger even isn't that important anymore, as the 'slow' signal passes voltage levels just once per edge. So the processor will see only one transistion per edge.
But I'm not sure and I haven't tested yet. Worth a try, as it makes the schematics and PCB design a lot simpler.
 

orthello

The Dutch Guy
VSS converter schematics
Some notes.
1) the 16F628 has an internal clock. Thats why no crystal. Set the clock to 4MHz, otherwise you need to change the devider at the output.

2) The devider at the output is because the PWM module in the 16F628 (@4MHz) can only produce square waves from 245Hz up to 32KHz.
The S2000 gauge requires minimal 26Hz for the slowest possible speed and about 7KHz for the highest possible speed. When using a 4 devider, we end up with an output from 60Hz to 8KHz. This is the best compromise. We can have the gauge show 2KM/h (or 1MPH) as the lowest possible speed, but up to the full scale 300KM/h
When deviding by 5 or more we can show lower speeds but the maximum speed to be displayed will be 230KM/h (145MPH) or even less when using a bigger devider.
Most of us are able to go faster then. But slower then 2KM/h.... Why would we want to know we are going sooooo sloooowwwww?? ;)

Bottom line... because the PWM module has a limited frequency range it can opperate in, we need to devide the output frequency to show lower speeds. But... the bigger the devider, the lower the maxmimum speed that can be displayed.

Running the processor on 4MHz and deviding the output by 4, is the best possible compromise, without any compromise to Vmax and a very very little (just 1km/h) compromise to Vmin.

If people have questions about this devider thing, please let me know. I'm aware that this is a tricky part, and giving a good explaination when English is not your native, is at least as tricky as the devider thing itself ;)
(My native is Dutch. I'm from Holland)




BTW... anybody knows some good sites with traffic rules for western USA? As I'm going to San Francisco, Los Angeles and Las Vegas in June... by (rental) car.
 

plummo_vtec

New Member
so setting this up will enable the cluster to read everything except ect ie i can have a working cluster in my car using this scematic
 

orthello

The Dutch Guy
so setting this up will enable the cluster to read everything except ect ie i can have a working cluster in my car using this scematic
When you also load the software (quoted above) in to the processor, you will have a nice VSS converter that makes your S2000 cluster work with other Honda VSS sensors.

Same thing can be used for other cars or cockpit's with pulsating VSS signals of different rates. Just do some minor changes to the software.
 
Top