Loisirs Sports Favoris
Visites
Nouvelles RSS
|
Cyclisme - VAE_Wattmètre Picaxe
WATTMETRE à uC Picaxe 18M2+ Construisons un wattmètre à afficheur Mesures U A propos de la mesure tension :Il faut un pont diviseur pour la mesure de la tension On peut mesurer du 150V voir plus, la seule contrainte est d'avoir au maxi 5V sur l'entrée Picaxe. Plus exactement une tension pas supérieur à l'alimentation du Picaxe. Plus le pont diviseur est élevé plus la précision baisse. Pour les novices voici les formules avec 2 résistances : par exemple R1 et R2 Vout=Vin*R1/(R1+R2) D'autre part il faut veiller à avoir une impédance pas trop forte (<10k environ) Z=R1*R2/(R1+R2) Dans le schéma j'ai mis 100k et 10k Donc si j'ai par exemple 50V en entrée ça donne : 50*10/(10+100)=4.54V donc conforme Si c'est au-dessus la diode va empêcher le picaxe de cramer. Pour simplifier, à 5V le picaxe peut voir 1023pas soit 5mv environ Pour les 50V les pas seront grosso modo de 50/1023 soit 0.05V environ Pour 100V ça tombe à 0.1V La solution -> autorange !avec 2 ponts diviseurs sur 2 voies du Picaxe. Mesures I Mesure du courant avec un shunt et un simple ampli op type LM358, 158 ou mieux.... Si c'est pour monter sur un E-bike TEST sur LI-ION Program Files (x86)Programming
EditorsamplesPicaxeSuperjcLCDparalelle18M_4bit_good
- 8car_v4_RamPokev5.1 #rem 2 ***Wattmeter LCD 4bit by SuperJC*** 3 The unit is based on a PICAXE 18M2 like
AXE133 but with only 4bit 4 _________________________________________ 5 ---_--- 6 in U 22-65V c.2 |1 18|c.1 in I 7 c.3 |2 17|c.0 in U 00-22V autorange with c.2 8 c.4 |3 16|c.7 LCD_4_RS 9 in c.5 |4 15|c.6 LCD_6_enable 10 0v |5 14|V+ 11 alarm b.0 |6 13|b.7 LCD_14_d7 12 b.1 |7 12|b.6 LCD_13_d6 13 b.2 |8 11|b.5 LCD_12_d5 14 b.3 |9 10|b.4 LCD_11_d4 15 ------- 16 _________________________________________ 17 18 * not free 19 w0 b1* b0* 20 w1 b3* b2* 21 w2 b5*SECONDS b4*Math and COMPTER 22 w3 b7*MINUTES b6*SECONDS1 23 w4 b9*HOURS b8*MINUTES1 24 w5 b11 b10 25 w6*Math b13 b12 26 w7*M_tampon
b15 b14 27 w8* b17 b16 28 w9*Math b19 b18 29 w10 b21*tenthousands
b20*thousands 30 w11 b23*hundreds b22*tens 31 w12 b25*units b24 32 w13*U b27 b26 33 _________________________________________ 34 35 Supported Commands for original LCD/OLED 36 ; 253, X display 16 character pre-saved
message from EEPROM memory, X can be 0-15 37 ; 254, X LCD command, X can be 0 to 255 38 39 #endrem 40 ;_________________________________________ 41 symbol line_length = 16 ; change to 20 for displays with 20
character lines 42 symbol enable = C.6 ; LCD enable 43 symbol rs = C.7 ; LCD RS 44 45 symbol M_W = 50 46 47 symbol M_mA = 52 48 symbol M_mA_last = 54 49 50 symbol M_mV = 66 51 symbol M_mV_last = 68 52 53 symbol M_mAhDiV = 70 54 symbol M_mAhLCD = 72 55 56 symbol M_Time36 = 74 57 symbol M_LCD = 100 58 ;_________________________________________ 59 symbol COMPTER=b4 60 symbol SECONDS=b5 61 symbol SECONDS1=b6 62 symbol MINUTES=b7 63 symbol MINUTES1=b8 64 symbol HOURS=b9 65 symbol tenthousands=b21 66 symbol thousands=b20 67 symbol hundreds=b23 68 symbol tens=b22 69 symbol units=b25 70 symbol M_tampon=w7 71 ;_________________________________________ 72 #picaxe 18M2_c 73 ;#picaxe 18M2 74 75 setfreq m4;or 16 (for time 1s) 76 77 EEPROM $00, ("SuperJC
4bit LCD") ' store the text in the EEPROM memory 78 EEPROM $10, ("Wattmeter ") ; store msg1 in the EEPROM memory 79 EEPROM $20, ("B1 B2 B3 ") ; store msg2 in the EEPROM memory 80 EEPROM $30, ("32.0 3.15 0.85") ; store msg3 in the EEPROM memory 81 EEPROM $40, ("This is msg
4 ") ; store msg4 in the EEPROM memory 82 EEPROM $50, ("This is msg
5 ") ; store msg5 in the EEPROM memory 83 EEPROM $60, ("This is msg
6 ") ; store msg6 in the EEPROM memory 84 EEPROM $70, ("This is msg
7 ") ; store msg7 in the EEPROM memory 85 EEPROM $80, ("This is msg
8 ") ; store msg8 in the EEPROM memory 86 EEPROM $90, ("This is msg
9 ") ; store msg9 in the EEPROM memory 87 EEPROM $A0, ("This is msg
10 ") ; store msg10 in the EEPROM
memory 88 EEPROM $B0, ("This is msg
11 ") ; store msg11 in the EEPROM
memory 89 EEPROM $C0, ("This is msg
12 ") ; store msg12 in the EEPROM
memory 90 EEPROM $D0, ("This is msg
13 ") ; store msg13 in the EEPROM
memory 91 EEPROM $E0, ("This is msg
14 ") ; store msg14 in the EEPROM
memory 92 EEPROM $F0, ("This is msg
15 ") ; use for wrchr
to LCD 93 94 gosub init ' initialise
LCD 95 96 disabletime 97 b1 = 1:gosub wrins254_b1:pause 10'clear LCD 98 b1 = 0:gosub wrins253_msg_b1'message b1 99 b1 = 192:gosub wrins254_b1'ligne
2 100 b1 = 1:gosub wrins253_msg_b1'message b1 101 pause 2000 102 b1 = 128:gosub wrins254_b1'ligne
1 103 b1 = 2:gosub wrins253_msg_b1'message b1 104 b1 = 192:gosub wrins254_b1'ligne
2 105 b1 = 3:gosub wrins253_msg_b1'message b1 106 pause 4000 107 b1 = 1:gosub wrins254_b1:pause 10'clear LCD 108 109 poke M_Time36,36'time every 36s 110 111 SERTXD ("mA,mV,mAh,S",cr,lf) 112 113 ;******************************************************** 114 ;******************************************************** 115 main: 116 117 gosub fonc_Uc0_W8 118 poke M_mV,word w9;STO mV 119 120 ;gosub fonc_ClearMemory15 121 ;write $F0,tenthousands,thousands,".",hundreds,tens,"
","V"," " ;w9 LCD[00.00 V ________]first 8 char
($F0) 122 ;b1 = 1:gosub wrins253_msg_b1'message b1 123 124 poke M_LCD,128,tenthousands,thousands,".",hundreds,tens," ","V"," " 125 ;b1 = 128:gosub
wrins254_b1'ligne1 LCD[00.00 V ________] 126 GoSub PrintDisplay 127 128 bintoascii w8,tenthousands,thousands,hundreds,tens,units 129 poke M_LCD,136,thousands,hundreds,tens,units," ","U","c","0" 130 ;b1 = 136:gosub
wrins254_b1'ligne1 LCD[________0000 Uc0] 131 GoSub PrintDisplay 132 133 ;*********alarm bat 36V pinB0 134 if w9 > 10 and w9 < 32000 then;alarm U 32V 135 high B.0:pause 300 136 else 137 Low B.0 138 end if 139 ;*********alarm 140 141 ;*********alarm bat 3.7V pinB1 142 if w9 > 10 and w9 < 3150 then;alarm U 32V 143 high B.1:pause 300 144 else 145 Low B.1 146 end if 147 ;*********alarm 148 149 ;*********alarm bat 36V pinB0 150 if w9 > 10 and w9 < 0850 then;alarm U 0.85V 151 high B.2:pause 300 152 else 153 Low B.2 154 end if 155 156 ;pause 500;temps de
basculement sur info suivante 157 158 gosub fonc_Ic1_W8 159 poke M_mA,word w9;STO mA 160 161 poke M_LCD,192,tenthousands,thousands,".",hundreds,tens,units,"A"," " 162 ;b1 = 192:gosub
wrins254_b1'ligne2 LCD[00.000A ________] 163 GoSub PrintDisplay 164 165 bintoascii w8,tenthousands,thousands,hundreds,tens,units 166 poke M_LCD,200,thousands,hundreds,tens,units," ","I","c","1" 167 ;b1 = 200:gosub
wrins254_b1'ligne2 LCD[________0000 Ic1] 168 GoSub PrintDisplay 169 170 peek M_mV,word w7 ;RCL mV 171 peek M_mA,word w9 ;RCL mA 172 173 w6 = 65535/w9*10/16*1000 ; u x i must
<65535 (40w) 174 ;if w7 < 20000 and w9 < 2000 then
;better accurate 175 if w7 < w6 then ;better accurate 176 w7=w7/25;V 177 w7=w9/25*w7;W 178 w7=w7/160;W 179 else 180 w7=w7/100;V 181 w7=w9/100*w7;W 182 w7=w7/10;W 183 end if 184 185 poke M_W,word w7 ;STO W 186 187 ;pause 500;temps de
basculement sur info suivante 188 189 peek M_mA,word w9 ;RCL mA 190 if w9 >100 then;>100mA 191 peek M_mV,word w7 ;RCL mV 192 pause 500;temps de
basculement sur info suivante 193 w6=w7/w9;hom 194 w7=w7//w9*10/w9 + 48;find decimal 195 bintoascii w6,tenthousands,thousands,hundreds,tens,units 196 poke M_LCD,136,thousands,hundreds,tens,units,".",w7," ","R" 197 ;b1 = 136:gosub
wrins254_b1'ligne1 LCD[________00000 R] 198 GoSub PrintDisplay 199 end if 200 201 pause 500;temps de
basculement sur info suivante 202 203 peek M_W,word w7 ;RCL W 204 bintoascii w7,tenthousands,thousands,hundreds,tens,units 205 poke M_LCD,136,tenthousands,thousands,hundreds,tens,".",units," ","W" 206 ;b1 = 136:gosub
wrins254_b1'ligne1 LCD[________0000.0 W] 207 GoSub PrintDisplay 208 209 210 if w8 > 9 then ;ofset 0mA = 8 pas 211 enabletime ;enabletime if mA > 1(adc) 212 peek M_mA,word w7 ;RCL mA 213 peek M_mA_last,word w9 ;RCL mA n-1 214 w7=w7+w9/2 ;faire une moyenne de I pendant les débits on (Imax 65536/2 =
32A) 215 SERTXD (#w7,",") ;*****for datalog 216 poke M_mA_last,word w7 ;STO mA n-1 217 218 peek M_mV,word w7 ;RCL mV 219 ;peek M_mV_last,word
w9 ;RCL mV n-1 220 ;w7=w7+w9/2 ;faire
une moyenne de U pendant les débits on 221 SERTXD (#w7,",") ;*****for datalog 222 ;poke 65,word w7 ;STO mV n-1 223 224 ;peek M_mAhDiV,word
w7 ;RCL mAh 225 226 ;*****for datalog 227 peek M_mAhDiV,word w9 ;RCL mAh 228 peek M_mAhLCD,word w7 ;big mAh 229 w9=w9/100; 230 w7=w9+w7; 231 SERTXD (#w7,",",#time,cr,lf) 232 ;***** 233 234 235 peek M_Time36,word w7 ;time every 36s 236 if time > w7 then ;chaque 36s on va cumuler les mah 237 peek M_Time36,word w7 ;time every 36s 238 w7 = w7+36 ;add 36s 239 ;SERTXD ("w7 ",#w7,"--",#time,cr,lf) 240 poke M_Time36,word w7 ;time every 36s 241 242 peek M_mA_last,word w7 ;RCL mA n-1 243 w7=w7 ;math 0,01 mAh 244 peek M_mAhDiV,word w9 ;RCL mAh 245 w7=w9+w7 ;cumul 246 poke M_mAhDiV,word w7 ;STO mAh 247 248 if w7>3600 then 249 peek M_mAhLCD,word w9 ;big mAh 250 w9=w7/100+w9 251 poke M_mAhLCD,word w9 ;big mAh 252 w7=0 253 poke M_mAhDiV,word w7 ;STO mAh 254 end if 255 end if 256 257 else 258 disabletime 259 end if 260 261 peek M_mAhDiV,word w9 ;RCL mAh 262 peek M_mAhLCD,word w7 ;big mAh 263 w9=w9/100; 264 w7=w9+w7; 265 266 bintoascii w7,tenthousands,thousands,hundreds,tens,units 267 poke M_LCD,200,tenthousands,thousands,".",hundreds,tens,units,"A","h" 268 ;b1 = 200:gosub
wrins254_b1'ligne2 LCD[________00.000Ah] 269 GoSub PrintDisplay 270 271 pause 1500 272 273 gosub fonc_TimeEnable 274 gosub fonc_U_picaxeW13 275 276 poke M_LCD,136,thousands,"v",hundreds,tens," ","P","i","c" 277 ;b1 = 136:gosub
wrins254_b1'ligne1 LCD[________0v00 Pic] 278 GoSub PrintDisplay 279 280 poke M_LCD,200,HOURS,"h",MINUTES1,MINUTES,"m",SECONDS1,SECONDS,"s" 281 ;b1 = 200:gosub wrins254_b1'ligne2
LCD[________0h00m00s] 282 GoSub PrintDisplay 283 284 pause 1000;temps de
basculement sur info suivante 285 286 goto main 287 288 end 289 '******************************************************** 290 291 init: 292 '######################################################## 293 '# Initiation subprocedure
for the LCD 294 '# 295 '# C.7 - 4 (RS) 296 '# C.6 - 6 (E) 297 '# B.7 - 14 (DB7) 298 '# B.6 - 13 (DB6) 299 '# B.5 - 12 (DB5) 300 '# B.4 - 11 (DB4) 301 '######################################################## 302 303 'let pinsC = 0
' Clear all output lines 304 let pinsC = 0 305 let pinsB = 0 306 let b3 = 0 ' Reset variable b3 307 308 let dirsC = %11000000 ; PortC 6,7 outputs 309 let dirsB = %11111111 ; PortB all outputs 310 pause 200 ' Wait 200 ms
for LCD to reset. 311 312 let pinsB = 48 'Set to 8-bit operation. 313 pulsout enable,1 ' Send data by pulsing ‘enable’ 314 pause 10 ' Wait 10 ms 315 pulsout enable,1 ' Send data again 316 pulsout enable,1 ' Send data again 317 318 let pinsB = 32 'Set to 4-bit operation 319 pulsout enable,1 ' Send data 320 pulsout enable,1 ' Send data again 321 322 let pinsB = 128 ' Set to two line operation 323 pulsout enable,1 ' Send data 324 325 let b1 = 14 ' Screen on, cursor on instruction 326 gosub wrins254_b1 ' Write instruction to LCD 327 return 328 329 330 331 PrintDisplay: 332 '####################################################################### 333 '# Write 8 Character
to LCD (Poke 100) M_LCD 334 '####################################################################### 335 peek 100,b1:gosub wrins254_b1 336 337 for COMPTER = 101 to 108 338 peek COMPTER,b1:gosub wrchr 339 next COMPTER 340 return 341 342 wrchr: 343 '####################################################################### 344 '# Write Character to LCD subprocedure,
sends one character to the LCD 345 '####################################################################### 346 347 'let b2 = b1 / 16 ' Put high nibble of
b1 into b2 348 'let pinsC =
b2 & 15 ' Mask the low nibble of b2 (%00001111) 349 let pinsB = b1 & 240 'Mask the high nibble of b1 into b2. 350 high rs ' Make sure RS is high 351 pulsout enable,1 ' Pulse the enable pin to send data. 352 let b2 = b1 * 16 'Put low nibble of b1 into b2. 353 let pinsB = b2 & 240 'Mask the high nibble of b2 354 high rs ' Make sure RS is high 355 pulsout enable,1 ' Pulse the enable pin to send data. 356 return 357 358 wrins254_b1: 359 '############################################################################ 360 '# Write Instruction to LCD - subprocedure, sends an instruction to the LCD 361 '############################################################################ 362 low rs;**** 363 let pinsB = b1 & 240 'Mask the high nibble of b1 into b2. 364 pulsout enable,1 ' Pulse the enable pin to send data 365 low rs;**** . 366 let b2 = b1 * 16 'Put low nibble of b1 into b2. 367 let pinsB = b2 & 240 'Mask the high nibble of b2 368 pulsout enable,1 ' Pulse the enable pin to send data. 369 high rs ' Back to character mode 370 return 371 372 373 wrins253_msg_b1: 374 '############################################################################ 375 '# Write Message (n°b1) to LCD - (from
EEPROM data memory into b1) 376 '############################################################################ 377 let b0 = b1 * line_length; EEPROM start address is 0 to
15 multiplied by 16(for LCD 16) 378 let b3 = b0 + line_length - 1; end address is start address + (line_length -
1) 379 for b4 = b0 to b3; for 16 times 380 read b4,b1; read next character from EEPROM data
memory into b1 381 gosub wrchr 382 next b4 383 return 384 385 ;wrins253_msg_b1_0_7: 386 '############################################################################ 387 '# Write Message (n°b1) to LCD - (from
EEPROM data memory into b1) 388 '############################################################################ 389 ;;let b0 = b1 * line_length;
EEPROM start address is 0 to 15 multiplied by 16(for LCD 16) 390 ;let b3 = b0 + line_length
- 1 - 8; end address is start address + (line_length -
1) 391 ;for b4 = b0 to b3; for 8 times 392 ; read b4,b1; read next character from
EEPROM data memory into b1 393 ;gosub wrchr 394 ;next b4 395 ;return 396 397 ;wrins253_msg_b1_8_15: 398 '############################################################################ 399 '# Write Message (n°b1) to LCD - (from
EEPROM data memory into b1) 400 '############################################################################ 401 ;let b0 = b1 * line_length
+ 8; EEPROM start address is 0 to 15 multiplied by 16(for LCD 16) 402 ;let b3 = b0 + line_length
- 1 -8; end address is start address + (line_length -
1) 403 ;for b4 = b0 to b3; for 8 times 404 ;read b4,b1; read next character from EEPROM
data memory into b1 405 ;gosub wrchr 406 ;next b4 407 ;return 408 409 fonc_TimeEnable: 410 '############################################################################ 411 HOURS=TIME/3600:HOURS=HOURS + 48;digit2 +48forASCIIcode 412 413 MINUTES1=TIME/60//60/10:MINUTES1=MINUTES1 + 48;digit1 +48forASCIIcode 414 MINUTES=TIME/60//60//10:MINUTES=MINUTES + 48;digit2 +48forASCIIcode 415 416 SECONDS1=time//60/10:SECONDS1=SECONDS1 + 48;digit1
+48forASCIIcode 417 SECONDS=time//60//10:SECONDS=SECONDS + 48;digit2 +48forASCIIcode 418 return 419 420 fonc_ClearMemory15: 421 '############################################################################ 422 write $F0," ","
"," "," "," ","
"," "," "," ","
"," "," "," ","
"," "," ";clear message 15 423 return 424 425 fonc_U_picaxeW13: 426 '############################################################################: 427 ;****************lecture de la tension interne du PicAxe 428 w13=0 429 for COMPTER = 1 to 20 430 calibadc10 w9; lecture
de la tension interne du PicAxe 431 w13=w13+w9 432 next compter 433 W13=w13/20 434 let w13 = 65472/w13*16+20;calcul de la tension réelle en mV
par JC 435 bintoascii w13,tenthousands,thousands,hundreds,tens,units 436 return 437 438
fonc_Uc0_W8: 439 '############################################################################ 440 ;****************lecture de la tension pont diviseur C.0 441 gosub fonc_U_picaxeW13 442 w8=0 443 for COMPTER = 1 to 40 444 READADC10 C.0,w9 445 w8=w8+w9 446 next compter 447 w8=w8/40 448 if w8 > 1020 then 449 gosub fonc_Uc2_w8 450 else 451 ;w9 = w8*58/10;_ofset for 100k by JC 452 w9 = w8*1/10;28.1 453 w9 = w8*28+w9;_ofset for 33k 22Vmax 20V=917pas
by JC 454 w9 = w13*10/1023*w8-w9;_5mV*adc+ofset=mesure / pont diviseur 455 bintoascii w9,tenthousands,thousands,hundreds,tens,units 456 end if 457 return 458 459 fonc_Uc2_W8: 460 '############################################################################ 461 ;****************lecture de la tension pont diviseur C.2 462 gosub fonc_U_picaxeW13 463 w8=0 464 for COMPTER = 1 to 40 465 READADC10 C.2,w9 466 w8=w8+w9 467 next compter 468 w8=w8/40 469 ;w9 = w8*58/10;_ofset for 100k by JC 470 w9 = w8*4/10;15.4 471 w9 = w8*15+w9;_ofset for 120k 65Vmax 36V=551pas
by JC 472 w9 = w13*10/1023*w8+w9;_5mV*adc+ofset=mesure / pont diviseur 473 bintoascii w9,tenthousands,thousands,hundreds,tens,units 474 return 475 476 fonc_Ic1_W8: 477 '############################################################################ 478 ;****************lecture de l'intensité sur C.1 479 gosub fonc_U_picaxeW13 480 w8=0 481 for COMPTER = 1 to 20 482 READADC10 C.1,w9 483 w8=w8+w9 484 next compter 485 w8=w8/20 486 ;w9 = w8*33;_ofset 5000ma = 381 pas
resistance 3.3khoms 487 w9 = w8*9/10;36.9 488 w9 = w8*36+w9;36.9 489 w9 = w13*10/1023*w8-w9-105;_5mV*adc+ofset=mesure 490 491 ; if w8<8 then 492 ; w9=0 493 ; end if 494 495 if w8<8 then 496 w9=65535-w9 497 bintoascii w9,tenthousands,thousands,hundreds,tens,units 498 tenthousands
= 045;- (minus) 499 w9=0 500 else 501 bintoascii w9,tenthousands,thousands,hundreds,tens,units 502 end if 503 if w8<2 then 504 tenthousands
= 45 ;- (minus) 505 thousands = 42 ;* 506 hundreds = 42 ;* 507 tens = 42 ;* 508 units = 42 ;* 509 end if 510 return 7 Date de création : 10/11/2012 @ 16:58 ![]() ![]() jan 2019_ api geoportail new key free
sept 2017_ api geoportail new key sept 2016_ api geoportail new key sept 2013_ api geoportail new key nov 2012 WATTMETRE à uC Picaxe 18M2+ sept 2012_ api geoportail v2.0.0 new key avril 2012 PAS DIGITAL à uC Picaxe 08M2 mars 2012_ api geoportail v1.3 new key mar2012 ajout Cyclisme - VAE_calcul_puissance courbe highcharts fev2012 ajout Cyclisme - VAE_calcul_puissance fev2012 ajout infos + calcul puissance dans google V3 fev2012 add thermal pictures ! fev2012 add Cycle Analyst V2.25 with Rev 11 PCB + Display 790 + PAS proportional dec 2011 pédalage proportionnel optimisé version AV2 nov 2011 ajout capteur pédalage proportionnel AV1 pour VAE 250W oct 2011 Article VAE 250W ajout infos sur selection partielle dans profil Amcharts aout 2011 ajout infos temps dans profil Amcharts juillet 2011 add function amClickedOnSeries for zoom in / out ajout profil dans geoportail version ApiGoogleChart et Amcharts ajout profil dans google v3 juin 2011 ajout 'sens' dans google v3 Ajout Fonction "rechercher" api Google v3 , click/polyline, Logo VCMB Ajout Score : indice difficulté Ajout TinyTableV3 Ajout zone upload (beta) mai 2011_ api Google v2 v3 Ajout echelle et centrage carte OSM Ajout Tri tableau avril 2011_ api OSM mars 2011_ api geoportail | Préférences
Se reconnecter --- ![]()
( personne )
Météo 78
Calendrier
Webmaster - Infos
|