...forum looks different from my last visit.
Anyways, this is a question about a particular bit of code that won't work properly on my custom microcontroller board. The board has an atmega328-au connected to two a4950 motor drivers, a servo input, and a 12V connection. That's it. It doesn't even have an external oscillator.
The input pins of the a4950s are on the atmega's PD5 and PD6, and PB1 and PB2. This is equivalent to D5, D6, D9, and D10 on a nano.
The output to the motor drivers works correctly. I can analogWrite() to them with no issues and even use libraries like TimerOne to write to them. They are programmed with a 0.2 ohm resistor to current limit at 2.5 amps, but I'm not sure if that's relevant. The current limiting does appear to work correctly.
However, for some reason the board absolutely refuses to work with any RC signal input library I've tried. RC Receiver kind of works, or at least the output on the motor driver changes when I change the input signal. It doesn't change correctly though, having very little variation in PWM duty cycle on the output. RCReceiver (different lib) doesn't work at all, sending a constant signal at about 50% duty cycle and a weirdly low pulse frequency to the motor, and ServoInput has the same result as RCReceiver.
Here is the code for the RC Receiver library test.
#include <RC_Receiver.h>
#include <TimerOne.h>
RC_Receiver receiver(0);
int read1;
int FWDwrite1A;
void setup() {
Serial.begin(9600);
Timer1.initialize(200);
}
void loop() {
read1 = receiver.getRaw(1);
FWDwrite1A = map(read1, 1000, 2000, 0, 255);
analogWrite(9, FWDwrite1A);
//Timer1.pwm(9, FWDwrite1A);
digitalWrite(10, 0);
Serial.println(FWDwrite1A);
}
Despite there being serial code, I am unable to access the serial monitor on this board at this time. The code is there from when I was testing this program on standard Uno R3s, and it works just fine on them although I have to substitute an LED for the motor output.
I have also placed an LED directly between pin 9 and ground, and the output on it is the same as the motor. This means the issue must be with the atmega somehow. Possibly the internal clock.
I have also attached a schematic of the motor driver board. It includes an AMS1117, but that was not soldered on the board I was testing with. Attempts that did use the AMS1117 yielded the same results. It also includes a second servo input, but using this input instead of the one on pin 0 changed nothing.
The reason the servo input is on pin 0 is because I want future support for more complex protocols.
Almost any additional information you may need is available, but I may take some time to post it due to school/sleep/general time zone mismatches.