Dual Battery Monitor Help Required.

Hi everyone,

So the story is I have a Dual Battery Monitor that has died.

I’ve found that the PIC 16f818 IC which drives the monitor has failed.

As the PIC is code protected i tried to source a new programmed pic from the manufacturer without any luck so the next step was to draw out the circuit and program a pic myself.

I’ve never programmed a pic before and don’t know how to code in C but have been having a go and trying to learn.

I’m having a really ruff time getting my head around it and feel at this stage I’ve bitten off more than I can chew.

Could somebody Kindly write the code required for me and then through study of the code it I could learn how this is to be done.

As I cannot upload a schematic file and operating requirements I’ve attached some links to these.(chose NLBMDAS for the operating details)

Many thanks,

Axle

https://goo.gl/photos/ZVzR2HCPjEc6rbrT8

https://goo.gl/photos/ZVzR2HCPjEc6rbrT8

http://www.nationalluna.com.au/technical-info-old/

That’s a very well drawn schematic.

You may be lucky to find someone who’s willing to do this for you for free, but based on my quick estimate, you’re looking at a minimum of 3-4 hours firmware development. Add a couple of hours testing, and that’s a substantial amount of work to do for free.

Is there another language you’re familiar with besides C? It might be easier to use an Arduino. The tools make them very easy to work with and an Arduino could be substituted for the PIC in your diagram quite easily (assuming there’s room for it in the physical enclosure).

Thanks, It did take a couple of redraws to make the led matrix easy to read.

yeah I’m trying to keep the cost down, I thought it would be straight forward for somebody that knows how to code.

The little knowledge I have in coding is only C, I’ve never played with Arduino before and no nothing about it.

Not to worry tho I will continue learning and trying to do this myself, it will just take some time.

This board works best if you have a particular part of the problem you need help with. e.g., you are trying to figure out how to turn the beeper on if the voltage is below a certain point, someone can help you easily. However, it doesn’t work well if you’re looking for a complete application to be written, because then the back and forth goes on for many, many pages, often with both sides getting frustrated. Just look at some of the longer threads that last for 10+ pages.

lyndon:
This board works best if you have a particular part of the problem you need help with. e.g., you are trying to figure out how to turn the beeper on if the voltage is below a certain point, someone can help you easily. However, it doesn’t work well if you’re looking for a complete application to be written, because then the back and forth goes on for many, many pages, often with both sides getting frustrated. Just look at some of the longer threads that last for 10+ pages.

No problem I understand.

On that note some opinions on this piece of code would be appreciated.

RB6 and RB7 are both inputs and the rest or channel B are outputs for the leds.

Is there a problem with setting outputs to inputs to clear the ports?

also is there any problems with using 28 void functions for the main led’s?

void led1()
{  
    TRISB = 0b11101110;
             PORTBbits.RB0=1;  
             PORTBbits.RB4=0;
             __delay_us(10);
    TRISB = 0b11111111;
}

I’m still miles from nowhere with this project so hopefully this will make some progress.

cheers.

I have worked with many different CPUs and architectures, but I have never touched a PIC.

That said, setting outputs to inputs will not force the output to be cleared (LOW) as it normally will put the pin in a tristate condition where you can’t guarantee its state.

There’s probably a better solution to controlling 28 LEDs than having 28 separate functions, but I don’t see any reason why it won’t actually work.

lyndon:
I have worked with many different CPUs and architectures, but I have never touched a PIC.

That said, setting outputs to inputs will not force the output to be cleared (LOW) as it normally will put the pin in a tristate condition where you can’t guarantee its state.

There’s probably a better solution to controlling 28 LEDs than having 28 separate functions, but I don’t see any reason why it won’t actually work.

I’m hoping somebody can chime in with a better solution but so far its the only one I can think of. I know very little about pic’s but assume there’s only a certain amount of code you can use and 28 separate functions would have to chew up quite a chunk.

Cleared is bad wording on my part. It is actually a tristate condition I’m after because if any other port is either high or low then it affects other leds in the matrix. Once again I don’t know any other way to do it.

HI everyone,

So its been a while and this project is still ongoing.

I’m having some trouble with the charlieplex side of things in that it uses up too much program space on the pic. I think I need to use some sort of table but after loads of searching I cannot work out how to code it. Any guidance here would be much appreciated.

below is the current code for the 28 leds charliplex.

thanks

VM=voltage main

VA=voltage AUX

delay=800uS

void LED(void)
  {    
    if (VM>=11.4){TRISB = 0b11101110,PORTB = 0b00000001,delay();}//1  
         
    if (VM>=11.6){PORTB = 0b00010000,delay();}//2
    
    if (VM>=11.8){TRISB = 0b11011110,PORTB = 0b00000001,delay();}//3
     
    if (VM>=12){PORTB = 0b00100000,delay();}//4
    
    if (VM>=12.1){TRISB = 0b11111100,PORTB = 0b00000001,delay();}//5   
    
    if (VM>=12.2){PORTB = 0b00000010,delay();}//6
    
    if (VM>=12.3){TRISB = 0b11111001,PORTB = 0b00000010,delay();}//7
    
    if (VM>=12.4){PORTB = 0b00000100,delay();}//8
    
    if (VM>=12.5){TRISB = 0b11111010,PORTB = 0b00000001,delay();}//9  
    
    if (VM>=12.6){PORTB = 0b00000100,delay();}//10
   
    if (VM>=13){TRISB   = 0b11001111,PORTB = 0b00010000,delay();}//11  
    
    if (VM>=13.2){PORTB = 0b00100000,delay();}//12
    
    if (VM>=13.7){TRISB = 0b11100111,PORTB = 0b00001000,delay();}//13
    
    if (VM>=14.2){PORTB = 0b00010000,delay();}//14
   
  
//-------------------------------------------------------------------------------------
  

    if (VA>=11.4){TRISB = 0b11110011,PORTB = 0b00000100,delay();}//15
    
    if (VA>=11.6){PORTB = 0b00001000,delay();}//16
        
    if (VA>=11.8){TRISB = 0b11101011,PORTB = 0b00000100,delay();}//17
    
    if (VA>=12){PORTB = 0b00010000,delay();}//18
    
    if (VA>=12.1){TRISB = 0b11011011,PORTB = 0b00000100,delay();}//19
    
    if (VA>=12.2){PORTB = 0b00100000,delay();}//20
    
    if (VA>=12.3){TRISB = 0b11110101,PORTB = 0b00000010,delay();}//21
    
    if (VA>=12.4){PORTB = 0b00001000,delay();}//22

    if (VA>=12.5){TRISB = 0b11101101,PORTB = 0b00000010,delay();}//23
   
    if (VA>=12.6){PORTB = 0b00010000,delay();}//24
  
    if (VA>=13){TRISB   = 0b11011101,PORTB = 0b00000010,delay();}//25
 
    if (VA>=13.2){PORTB = 0b00100000,delay();}//26
    
    if (VA>=13.7){TRISB = 0b11110110,PORTB = 0b00000001,delay();}//27
   
    if (VA>=14.2){PORTB = 0b00001000,delay();}//28
    
    TRISB = 0b11111111;
    }