Author Topic: PIC driven fan repair  (Read 6612 times)

0 Members and 1 Guest are viewing this topic.

Online Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 663
  • Country: us
Re: PIC driven fan repair
« Reply #25 on: March 10, 2023, 12:16:45 pm »
It looks like there is only a single input for the Hall sensor.  How are you getting four states?
There's no point getting old if you don't have stories.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #26 on: March 12, 2023, 06:19:37 pm »
It looks like there is only a single input for the Hall sensor.  How are you getting four states?

It's just what ChatGPT gave me to work with. I thought it jsut counts the inputs? 
There is only one hall sensor.

But there are some good news, I got the heat elements and the electrical seat-adjustment running.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #27 on: March 16, 2023, 04:49:15 pm »
I deleted the preivous update, because I found a problem with the code I wrote.

So the new code is:

Code: [Select]
#include "Includes.h"
// Define PWM pin
#define MOSFET1 GP4
#define MOSFET2 GP5



void interrupt ISR(void)
{
if(GP3)  //If HALL is triggered
{
if(T0IF)  //If Timer0 Interrupt
{
if(MOSFET1) // if MOSFET1 is high
{
MOSFET1 = 0;
TMR0 = PWM;
}
else      // if MOSFET1 is low
{
MOSFET1 = 1;
TMR0 = 255 - PWM;
}

T0IF = 0;   // Clear the interrupt
__delay_us(750);
MOSFET1 = 0; // Deactivate MOSFET1
}
}
if (GP3 == 0)
{
if(T0IF)  //If Timer0 Interrupt
{
if(MOSFET2) // if MOSFET2 is high
{
MOSFET2 = 0;
TMR0 = PWM;
}
else      // if MOSFET2 is low
{
MOSFET2 = 1;
TMR0 = 255 - PWM;
}
}
T0IF = 0;   // Clear the interrupt
__delay_us(750);
MOSFET2 = 0; // Deactivate MOSFET2

}
}

PWM is changeable in main, this is just the interrupt.
The fan is actually spinning better now, but still hits current spikes.

Here is a small video of the fan running this program without the 10 second delay and PWM set to 200.
https://youtu.be/Zp5g3TAAXDA

The clicking sound is just over current protection of the power supply.
Edit: updated code. Spins now with about 10.000rpm but doesn't start on it's own.
« Last Edit: March 17, 2023, 10:57:46 am by StAngus »
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #28 on: March 17, 2023, 06:47:00 pm »
I got the timing right, so the fan is spinning correctly now and the power supply doesn't go nuts anymore.
BUT it doesn't start spinning on its own now.

I tried to write a simple code to give it a nod in the right direction, but if I do this, everything stops working.

Code: [Select]
void main()
{
ANSEL  = 0x00;       // Set ports as digital I/O, not analog input
ADCON0 = 0x00; // Shut off the A/D Converter
CMCON  = 0x07; // Shut off the Comparator
VRCON  = 0x00;      // Shut off the Voltage Reference
TRISIO = 0x08;       // GP3 input, rest all output
GPIO   = 0x00;       // Make all pins 0


InitPWM(); // Initialize PWM

PWM = 180; // 50% duty cycle

while(1)
{
}
}

This is the main.c , if I put a function like "void start(void)" with some code after that, it only does that and nothing else. I tried return at the end, but to no avail.

I searched some stuff on google of course, but it's hard for me to differentiate between C and C++ and even if it is C, some things just don't work. I think it's because of the rather old HI-Tech compiler I'm using. 
 

Online Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 663
  • Country: us
Re: PIC driven fan repair
« Reply #29 on: March 18, 2023, 02:51:29 am »
Put your start code before the while(1) statement in main without making it a function.
There's no point getting old if you don't have stories.
 
The following users thanked this post: StAngus

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #30 on: March 18, 2023, 06:43:25 am »
Thank you so much, that was the error. Now only some optimization left to do.
But first some breakfast and coffee.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #31 on: March 18, 2023, 08:57:15 pm »
Ok, I'm done now.
After trying for hours I just can't get the RPM above 3600. Maybe it's just the limitation of the motor, even if it should be 5400 @ 12V.

Maybe I'll need a more advanced algorithm, but that's just out of my league.

My final code:
ISR.c
Code: [Select]
void interrupt ISR(void)
{
if(GP3)  //If HALL is triggered
{
if(T0IF)  //If Timer0 Interrupt
{
if(MOSFET1) // if MOSFET1 is high
{
MOSFET1 = 0;
TMR0 = PWM;
}
else      // if MOSFET1 is low
{
MOSFET1 = 1;
TMR0 = 255 - PWM;
}

T0IF = 0;   // Clear the interrupt
__delay_us(fandelay);
MOSFET1 = 0; // Deactivate MOSFET1

}
}
if (GP3 == 0)
{
if(T0IF)  //If Timer0 Interrupt
{
if(MOSFET2) // if MOSFET2 is high
{
MOSFET2 = 0;
TMR0 = PWM;
}
else      // if MOSFET2 is low
{
MOSFET2 = 1;
TMR0 = 255 - PWM;
}
}
T0IF = 0;   // Clear the interrupt
__delay_us(fandelay);
MOSFET2 = 0; // Deactivate MOSFET2


}
}
Include.h
Code: [Select]
#ifndef __INCLUDES_H
#define __INCLUDES_H
#define MOSFET1 GP5
#define MOSFET2 GP4
 

#include <htc.h> 
#define _XTAL_FREQ   4000000
#define fandelay 600
#include "PWM.h"
#include "ISR.h"


#endif
main.c
Code: [Select]
#include "Includes.h"

// Config word
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF);


// Main function
void main()
{
ANSEL  = 0x00;       // Set ports as digital I/O, not analog input
ADCON0 = 0x00; // Shut off the A/D Converter
CMCON  = 0x07; // Shut off the Comparator
VRCON  = 0x00;      // Shut off the Voltage Reference
TRISIO = 0x08;       // GP3 input, rest all output
GPIO   = 0x00;       // Make all pins 0


MOSFET2 = 1;
__delay_ms(50);
MOSFET2 = 0;

MOSFET1 = 1;
__delay_ms(50);
MOSFET1 = 0;
__delay_ms(200);
MOSFET2 = 1;
__delay_ms(50);
MOSFET2 = 0;
MOSFET1 = 1;
__delay_ms(50);
MOSFET1 = 0;

InitPWM(); // Initialize PWM

// PWM=0 means 0% duty cycle and
// PWM=255 means 100% duty cycle
PWM = 50; // 50% duty cycle


while(1)
{
}
}

The fan draws about 350mA whitch exeeds the 260mA in the specification, but that's good enough for Australia, not Austria.

Shout out sohttps://saeedsolutions.blogspot.com for providing a base code to work on.
« Last Edit: March 18, 2023, 08:59:08 pm by StAngus »
 

Online Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 663
  • Country: us
Re: PIC driven fan repair
« Reply #32 on: March 19, 2023, 12:52:53 am »
I would try to reduce the pulse width to the FETs. You’ll need to use a timer.
There's no point getting old if you don't have stories.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #33 on: March 19, 2023, 06:42:07 am »
I appreciate your input, but there is no way I could implement that on my own. I don't even know why it only works with the delays at that place.
It's like the old PC in the corner of the office, nobody knows what it is doing, but without it nothing works.

Maybe if I had an oscilloscope I could visualize what is happening in the timer 0 section, but I don't have one.

Feel free to post a code I could test, but my mental capacity for this project is gone.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9197
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: PIC driven fan repair
« Reply #34 on: March 19, 2023, 03:38:16 pm »
After trying for hours I just can't get the RPM above 3600. Maybe it's just the limitation of the motor, even if it should be 5400 @ 12V.
Sounds like it uses field weakening at high RPM. Also note that automotive "12V" is actually more like 14.4V.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #35 on: March 29, 2023, 09:03:16 pm »
Ok, just ordered a new fan, as I didn't want to rip the other one apart too. The metal halfs a riveted together and the PCB is enclosed plastic,. which you have to break apart.
Quess what: Doesn't spin and draws 3mA just like the ones I already got.
So it looks like it really needs something to be activated.
I broke open the controll modul to see, how the fan is activated.
It shares a common ground with the connector for the heating elemen. The positiv comes from a VN750S.
From my understanding, it is just a fancy MOSFET, so the board computer can switch the fan on and off via the can bus.
What am I missing here?

I tried with some higher voltage, but to no avail.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: PIC driven fan repair
« Reply #36 on: March 29, 2023, 10:38:56 pm »
Have you tried feeding it a PWM signal?

The easiest solution here would be finding someone that has the kind of car the fan came from and scoping the signal. Maybe you can find a forum dedicated to maintaining such cars?
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #37 on: March 30, 2023, 04:18:13 pm »
Yeah, PWM; was the second thing I tried. Looking at the PCB I don't know how that would change things.
If the VN750S to create a PWM signal, only Vcc of the PIC would get it.

I tried everything on the volvo side first, but ther just isn't any details to get and I wouldn't bother anyone with an  Volvo V70III to get a portable scope underneath their carseat.

In the end, it's just a fan and not rocket science. Every extra step would cost more money, and no manufacture like that.

There are LIN controlled fans, but they have 3 wires.

Also, I still don't understand what Pin6 does. It's connected to ground via a 6,1k resistor.
 

Offline StAngusTopic starter

  • Contributor
  • Posts: 21
  • Country: de
Re: PIC driven fan repair
« Reply #38 on: March 31, 2023, 11:19:24 am »
Quote
Also, I still don't understand what Pin6 does. It's connected to ground via a 6,1k resistor.

I was blind here. It also is connected to the input voltage over a 20k resistor. So it it is possible that the V750S is creating some kind of signal
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: PIC driven fan repair
« Reply #39 on: March 31, 2023, 04:51:26 pm »
What you describe sounds like a voltage divider that takes a sample of the input voltage and feeds it to that pin.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf