Quantcast
Channel: Reprap Forum - Firmware - Marlin
Viewing all articles
Browse latest Browse all 12090

Re: Fan etc on external i2c-controller

$
0
0
This is initialization, only needs to be done once

M260 A64
M260 B0
M260 B1
M260 S1

this turns on the led0 and sets the PWM 0/4095 (0 On/4095 Off, this is reverse of what is expected, but works)
M260 A64
M260 B6  ;LED_0_ON_L register address see registers 6 - 69 . Each Led has 4 registers a ON_L, ON_H, OFF_L and OFF_H
M260 B0
M260 S1

M260 A64
M260 B7 ;LED_0_ON_H  
M260 B0
M260 S1

M260 A64
M260 B8 ;LED_0_OFF_L
M260 B255
M260 S1

M260 A64
M260 B9 ;LED_0_OFF_H
M260 B15
M260 S1

so to turn it off you would send
M260 A64
M260 B6  ;LED_0_ON_L register address see registers 6 - 69 . Each Led has 4 registers a ON_L, ON_H, OFF_L and OFF_H
M260 B255
M260 S1

M260 A64
M260 B7 ;LED_0_ON_H  
M260 B15
M260 S1

M260 A64
M260 B8 ;LED_0_OFF_L
M260 B0
M260 S1

M260 A64
M260 B9 ;LED_0_OFF_H
M260 B0
M260 S1

and to turn on say led13

M260 A64
M260 B58  ;LED_13_ON_L  (led * 4 +6, led is in range  at 0..15) So we want led 13, 13*4+6 = 58
M260 B0
M260 S1

M260 A64
M260 B59 ;LED_13_ON_H (+1 from  LED_13_ON_L)
M260 B0
M260 S1

M260 A64
M260 B60 ;LED_13_OFF_L (+2 from  LED_13_ON_L)
M260 B255
M260 S1

M260 A64
M260 B61 ;LED_13_OFF_H (+3 from  LED_13_ON_L)
M260 B15
M260 S1

Each led takes two values On time and Off time, these can have values from 0..4095
If you have ever looked at how computers store numbers you know that a 8 bit number can only be 0..255, so to store 0..4096 you need two bytes, one is called L for low byte and the other H for high byte.

Calculating L and H values

Say you want to set 75% on,25%off (always has to add up to 100 %)
4095 * 0.75 = 3071, off value (remember its reversed, must be a whole number)
4095 - 3071 = 1024, on value

Easiest way to split into L and H is to convert it to Hexadecimal
3071 = BFF hex, you split this into two B and FF. B is the High value and FF is the Low value, then just convert it back to decimal, B = 11 and FF is 255
So you end up with H11 and L255
1024 = 400 hex so you end up with H4 and L0

full on is 4095 = FFFhex, F is high, FF is low, F = 15 and FF = 255, so you end up with Low = 255, High = 15

Viewing all articles
Browse latest Browse all 12090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>