Isn’t the DIR pin just a digital high or low? Not sure why you would want to set the frequency on that…
For pin 9 (Free3) calling anlogWriteFrequency() will affect TIM2, which is used for PWM on Free1, Free2, Free3 (and the status LED.)
For pin 2 (data2), calling analogWriteFrequency() will affect TIM1, which is normally used for WS2811 protocol generation. If you do that you can’t use neopixels anymore.
Im using a DRV8256P motor driver that has IN/IN interface which requires both pins to have pwm enabled. Do you think analogWrite would work? Or is it best to stick with LSanalogWrite?
I would recommend LSanalogWrite, but it will require a little coding to support 20kHz.
You can try it with analogWrite, just remember that you might get some glitching if you do it that way, should be fine for some basic testing though.
If at all possible, try using two of the Free* pins for this as that will not interfere with other timers.
I looked up the spec for this, and it also has a PH/EN interface which seems much easier to use. One digital line for direction and one PWM for the speed.
The IN1/IN2 interface seems to give direct control of the two outputs, but I’m not sure why anybody would want that.
Also, why 20kHz ? The chip says it supports 0 to 100kHz.
the DRV8256E has PH/EN Interface, but i am using the DRV8256P, with the DRV8256P i can introduce “braking” for instant stopping instead of coasting to a stop. So thats why i need both pins to have pwm
Believe me, it’s weird to program as well lol. Im kinda stuck using data 2 for one of the pins unless i want to resolder some wires. I have free 3 and data 2. I see on the proffie mapping chart that data 2 has pwm when there are no pixels. What does that mean? When there are no pixel connected to the pin?
Edit: The motor direction is not working correctly. Here is the code im testing in the setup function
void startMotor(bool direction) {
if (direction) {
LSanalogWrite(MOTOR_IN_1, slowDownPwm); // PWM to IN1
LSanalogWrite(MOTOR_IN_2, 0); // IN2 must be explicitly LOW
Serial.println("running motor forward...");
} else {
LSanalogWrite(MOTOR_IN_1, 0); // PWM to IN1
LSanalogWrite(MOTOR_IN_2, slowDownPwm); // PWM to IN2
Serial.println("running motor backward...");
}
motor_running = true;
}
when the program runs, the motor only turn one way then stops. However, if i was to test the startMotor with only one reference in the setup, it runs in both directions, meaning, if setup only has startMotor(true); or startMotor(false); it will run in that direction. But if i try to call the startMotor function multiple times it will not change directions, could this be an issue with the Proffie board and pwm?
Any pin?!? oh wow, ok that wont work then, i plan on having a battery indicator using the neo pixel strip, so ill try to free up Free 1 and work with that. Thanks for the info!
Its working now, i had to switch from using data 2 to free 1. So you were right, even though i had no pixels hooked up at all, data 2 pin was still not good for the pwm signal. the free pads as the way to go!
@profezzorn another question in regards to data 1 pin, can i use that one to control a mosfet module, this one in particular?
I currently have it connected to free 2 and it works fine however i need to use free 2 for the motor encode wire. Is data 1 ok to use to control the module? I see it says is resistored.
no, I need more Free pins, all the free pins are used up for the motor driver and encoder. I just need another pin for the mosfet module which controls my 12v LED cob strip. I tried hooking it up to the data 1 pin, but as soon as i turn on the board, the led on the mosfet module lights up dimly. I set data 1 to OUTPUT and LOW. Im controlling the LED strip on my own so i will not be using the proffie for lighting effects. I mainly want the proffie for the sound effects and and motion effects.
I need to trigger the mosfet module to turn the cob strip on and off, the mosfet is fed by a step up converter which provides a stable 12v. My strip only has two wires, pos and neg, so how would you control the strip through the LED pin alone? Aren’t the LED pins meant for a data line?
What i have right now is the trigger wire of the mosfet module connected to the LED 3 (22) pin. Currently this is not working:
LED1-6 are meant to drive the negative side of a LED.
(I’m not sure where the confusion comes from here, LED* is for power, data* is for data…)
They have fairly powerful FETs already on them.
Normally we use these to drive things that run on battery voltage, but then can definitely handle 12v. (In most cases they can handle up to 30v, but it depends on what actual FETs the manufacturer used, so you would need to read the symbols on your FETs and find the datasheet to find the actual limit.)
To wire it up, you hook up the + of your (COB) led to 12v, and the negative to one of LED1/2/3/4/5/6, then you configure it with SimpleBlade and it should just work.[1]
[1] There is one assumption here, which is that the ground is the same for your 12v circuits and your 4.2 volt circuits, which is normally the case. If not, they would just need to be connected together to make that the case.
Thanks for clarifying! That would make my setup a bit less complex. One thing I’m doing currently is, i wrote a function to flicker the cob strip by setting the MOSFET module HIGH and LOW randomly. Since I’m a NOOB in the proffie world, can i assume the SimpleBlade method could handle this type of effect? If so, could please provide an example of this or point me to the documentation for it?
Thanks again!
Yes. ProffieOS will set up a PWM counter @ 813 Hz to drive the fet, and it will repeatedly ask the style (which is the example in the previous post) to decide the PWM level.
The styles I posted might not look the same, but we have a number of random functions to choose from, so hopefully something with strike your fancy.