Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

Author Topic: PWM 3-Wires Fan Controller with RPM feedback (Pulse Stretching Method)  (Read 13440 times)

0 Members and 1 Guest are viewing this topic.

George

  • Jr. Member
  • **
  • Posts: 73
I agree with kam, try putting a 10k pot between +5V and ground with the contrast pin on the wiper (centre pin of the pot) & adjust it until you can see your display characters

Teza

  • Guest
Already done this :)
Noticed that with a 10K pot only the first line with boxes showed for a moment before both lines with boxes showed.
I can adjust the contrast so low that the boxes won't show, but no letters is visible.
Have bought some resistors today and will try to include them in the circuit, just to have tryed this.
« Last Edit: May 04, 2012, 01:43:55 AM by Teza »

Teza

  • Guest
Weekend again  :)



1 small step furter, it now updates but I am not quite ready to learn chineese yet.
Resistors connected and the circuit is changed so there also is +5V to pin 3 of R5, pin 3 of the LCD goes to pin 2 of R5 and pin 1 of R5 goes to ground. (as in the datasheet of parallax).
Got a feeling it might still be some bad connections with the LCD tho...

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
Are these real letter  :o :o :o :o :o :o :o ????????????

Teza

  • Guest
Let's put it another way, what do I look for when choosing a correct LCD for this circuit?  ;)

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
Let's put it another way, what do I look for when choosing a correct LCD for this circuit?  ;)

1st: The controller - should 99% be hd44780 or compartible if you look for character LCD
2nd: The characters (unless you can read those ideograms)
3rd: Connectivity. There are several LCDs with this controller but with attached serial or other connection board. I never use them, i prefer ye old 4-bits data transmission
4th: Backlit

That's just about it.

Teza

  • Guest
In that case I had a bit luck when I bought the MC44005A main display from Midas for the circuit.

I was thinking on the programming of the display (I currently use) in the PIC.
I read the program code (not understanding much at the moment) and wonder if the character code fitted the following list from the datasheet of the display that I currently use?



Code: [Select]
Start
bank1 ;Go to bank 1
movlw b'00111011' ;
movwf TRISA ;Set the port pin types of the RA
movlw b'11000001' ;
movwf TRISB ;Set the port pin types of the RB
bank0 ;Go to bank 0
movlw b'00000100'
movwf t2con
bank1
movlw b'01100000'
movwf pr2
bank0

movlw GLSpeedDC_Startup
movwf ccpr1l
movlw b'00001101'
movwf ccp1con
;Setup TIMER 0
bank1
bsf OPTION_REG,T0CS
bcf OPTION_REG,T0SE
bsf OPTION_REG,PSA
bcf OPTION_REG,PS2
bcf OPTION_REG,PS1
bcf OPTION_REG,PS0
bank0
bcf T1CON,TMR1ON
bcf T1CON,T1OSCEN
bcf T1CON,NOT_T1SYNC
bcf T1CON,TMR1CS
bsf T1CON,T1CKPS1
bcf T1CON,T1CKPS0

;Setup Interrups
clrf INTCON
call wait250msec
call wait250msec
call LCD_Initialize
call wait250msec
call LCD_DisplayTurnOn
call LCD_CursorTurnOff
call LCD_Clear
;Entry mode set
movlw b'00000000'
call LCD_SendByte
movlw b'01100000'
call LCD_SendByte
call wait10msec
call wait250msec
call wait250msec
movlw b'00000000'
CALL LCD_SetCursorPosition
movlw 'P';
call LCD_ShowCharacter
movlw 'W';
call LCD_ShowCharacter
movlw 'M';
call LCD_ShowCharacter
movlw ' ';
call LCD_ShowCharacter
movlw ' ';
call LCD_ShowCharacter
movlw 'F';
call LCD_ShowCharacter
movlw 'A';
call LCD_ShowCharacter
movlw 'N';
call LCD_ShowCharacter
movlw b'01000101'
CALL LCD_SetCursorPosition
movlw 'r';
call LCD_ShowCharacter
movlw 'p';
call LCD_ShowCharacter
movlw 'm';
call LCD_ShowCharacter
movlw d'40'
movwf ccpr1l
bank1
bsf ansel,1
clrf adcon1
bsf adcon1,ADCS2
bank0
movlw b'10001001'
movwf adcon0
Mainloop
call wait250msec
bsf adcon0,GO_DONE
btfsc adcon0,GO_DONE
goto $-1
movf adresh,w
movwf ccpr1l
call wait250msec
bsf adcon0,GO_DONE
btfsc adcon0,GO_DONE
goto $-1
movf adresh,w
movwf ccpr1l
movlw b'01000000'
CALL LCD_SetCursorPosition
bsf ledpin
call GetRPMCount
bcf ledpin
movf PassArg6,w
addlw 0x30
call LCD_ShowCharacter
movf PassArg5,w
addlw 0x30
call LCD_ShowCharacter
movf PassArg4,w
addlw 0x30
call LCD_ShowCharacter
movf PassArg3,w
addlw 0x30
call LCD_ShowCharacter
goto MainLoop
GetRPMCount
bcf T1CON,TMR1ON
clrf TMR1H
clrf TMR1L
movf ccpr1l,w
movwf PassArg13
movlw GLSpeedDC_100
movwf ccpr1l
nop
nop
nop
btfss RPMInputPin
goto $-1
btfsc RPMInputPin
goto $-1
bsf T1CON,TMR1ON
btfss RPMInputPin
goto $-1
btfsc RPMInputPin
goto $-1
bcf T1CON,TMR1ON
movf PassArg13,w
movwf ccpr1l
movlw b'11100100'
movwf passarg1
movlw b'11100001'
movwf passarg2
movlw b'11000000'
movwf passarg3
clrf passarg4
movf TMR1h,W
movwf passarg5
movf TMR1l,W
movwf passarg6
call Divide24By24
movf passarg3,w
movwf passarg1
call b16_d5
return
LCD_SetCursorPosition
movwf passarg1
andlw b'00011111'
movwf passarg2
movlw b'11000000'
andwf passarg1,f
bcf carry
rlf passarg1,f
rlf passarg1,f
rlf passarg1,f
movlw 0x00
movf passarg1,f
btfsc zero
goto LCD_SetCursorPosition_Next
movlw 0x40
decf passarg1,f
btfsc zero
goto LCD_SetCursorPosition_Next
movlw 0x94
decf passarg1,f
btfsc zero
goto LCD_SetCursorPosition_Next
movlw 0xd4
LCD_SetCursorPosition_Next
addwf passarg2,f
bsf passarg2,7
movlw b'11110000'
andwf passarg2,w
call LCD_SendByte
swapf passarg2,f
movlw b'11110000'
andwf passarg2,w
call LCD_SendByte
call wait10msec
RETURN
LCD_ShowCharacter
movwf PassArg1
bsf LCDRS
call LCD_SendByte
swapf PassArg1,w
call LCD_SendByte
bcf LCDRS
return

LCD_Initialize
movlw b'00110000'
call LCD_SendByte
movlw b'00110000'
call LCD_SendByte
movlw b'00110000'
call LCD_SendByte
movlw b'00100000'
call LCD_SendByte
call wait10msec
movlw b'00100000'
call LCD_SendByte
movlw b'11100000'
call LCD_SendByte
return

LCD_Clear
movlw b'00000000'
call LCD_SendByte
movlw b'00010000'
call LCD_SendByte
return

LCD_DisplayTurnOff
movlw b'00000000'
call LCD_SendByte
movlw b'10100000'
call LCD_SendByte
return

LCD_DisplayTurnOn
movlw b'00000000'
call LCD_SendByte
movlw b'11100000'
call LCD_SendByte
return

LCD_CursorTurnOn
movlw b'00000000'
call LCD_SendByte
movlw b'11100000'
call LCD_SendByte
return
LCD_CursorTurnOff
movlw b'00000000'
call LCD_SendByte
movlw b'11000000'
call LCD_SendByte
return
« Last Edit: May 05, 2012, 14:47:59 PM by Teza »

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
If you use my code unchanged, then i never used such characters. Moreover, this character is nowhere to be found in this charset. Ar you sure you have the correct lcd version/

Teza

  • Guest
Was thinking on the binary numbers in your code as the upper 4 bits and lower 4 bits in the table over.
Then thought that maby different LCD's may supported different character sets, and that the same character code on two different LCD's might displayed different character.

Like if you swapped the characters in the table over from:
00110000 = 0
10110000 = -
to:
00110000 = -
10110000 = 0

But as you mentioned the character on the display is not even in the table over.
Was just trying to figure out why the characters was wrong and therefore thought on different character tables for different displays when reading the datasheet...

Edit:
Have ordered new LCD.
« Last Edit: May 06, 2012, 01:33:44 AM by Teza »

Teza

  • Guest
Finaly got the new equipment and a new LCD is connected as follow:



When turning the circuit on, the bottom line shows a full line of black boxes for a short time.
Then both lines shows a full line of black boxes.
It seems like the LCD is getting signal updates as there is a kind of flashing regulary.

Adjusting contrast is not helping, just showing black boxes or nothing.

LCD datasheet 1
LCD datasheet 2

I just do not get this, am I connecting wrongly somehow?
I count the pins of the PIC as showed in reply#3 in this thread.
The source code is not changed.

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
What you describe seems to me as a wrong contrast. The one black line during startup are good news, and also the fact that this line then disappears (or becomes 2 lines) are also good news, which shows that the LCD is not broken and it initializes from the controller. But the contrast works also for you (you have a pot from grond to 5V and you supply the contrast pin with the middle take of the pot, right?).
I'm afraid that i run out of ideas  :-\

Teza

  • Guest
Actually no, but have tested it now.

Pin 1 pot - Ground
Pin 2 pot - LCD pin 3
Pin 3 pot - +5 V

Black boxes on 2nd line, disappear after short time and then boxes on both lines. Turn pot to left for higher contrast.

Pin 1 pot - +5 V
Pin 2 pot - LCD pin 3
Pin 3 pot - Ground

Same as the first as expexted, only turn the pot to the right

Pin 1 pot - Ground
Pin 2 pot - Ground
Pin 3 pot - LCD pin 3

This is how I read your circuit but I might be wrong.
Black boxes on 2nd line, disappear after short time and then boxes on both lines. Turn pot to left for higher contrast.

Using a 10K pot, tryed with a 2K pot with no differense, do not have a 20K pot for testing.
From the potmeter datasheet:


Edit:

When looking on the picture of your working circuit it looks like the LCD is connected to pin 15 and maby 16 of your PIC, is this correct?
(yellow and brown wire, instead of 12 and 13 as in the drawing.)
Migth be wrong but it looks like it when I zoom in on the picture...

Have tried to move the wire from pin 12 and 13 to pin 15 and 16 of the PIC and changing letters appear on the LCD.
It is not correct viewed on the LCD, but at least it shows random letters.
« Last Edit: May 20, 2012, 16:49:35 PM by Teza »

Teza

  • Guest
Now don't hate me, I am only trying to find out what is not working ;)
I have been following the wires on your testboard and compared it to the circuit drawing.

I have to say that there is some guessing as it is very hard to see what goes where on the board.

In this picture I have marked with red where I dont see a match:
(Click on image for larger verson)


Is it me who are wrong or is there an error in the drawing?
I think there is a small difference but might be reading the schematic wrong.

Update:

Did not help much when trying to connect it differently tho...
Current circuit, connected as the schematic shows, unless I have done something wrong.

« Last Edit: May 20, 2012, 22:36:39 PM by Teza »

kam

  • Administrator
  • Hero Member
  • *****
  • Posts: 1849
PIC pin 4 D and R are only for the ICSP connector, so just ignore them.

From the assembly listing:
#define RPMInputPin porta,4
#define PWMPin portb,3
#define LEDPin porta,2

;#define LCDRW portb,5
#define LCDRS portb,4
#define LCDE portb,5

#define LCD_P7 portb,2
#define LCD_P6 portb,1
#define LCD_P5 porta,7
#define LCD_P4 porta,6

So there are indeed errors. For some reason, i wrote "a" instead of "b" for LCD_P4 and LCD_P5. It should be:
#define LCD_P5 portb,7
#define LCD_P4 portb,6


Please do not hate me :D. I will upload the new version with this correction. If it works, please feedback.

Teza

  • Guest
Can't hate you, you're too kind ;)

Must say that I felt like a kid on x-mas eve when programing and reconnected the PIC.
Then nothing worked...
But after the second try of programing the PIC, the circuit worked as before.

Sadly there is no change in behaviour of the LCD, but hey, one step closer.
Thanxs!

Maby what I need is to find a simple program just to test the LCD to eliminate there beeing problems with it? Your PIC toturial book have not evolved this far yet, but there must be something about it on the net. (have not started to learn coding yet myself, wanted to get this circuit working first :) )

Update:
Had to try with the parallax LCD as well just to see, but with the same resolt.
« Last Edit: May 21, 2012, 22:17:23 PM by Teza »