Hello,
Okay. First off, the lib. does not provide perse PWM handling the Servo Header on the BBBlue. The PRU provides this mechanism via source to handle PWM on the Servo Header.
I think I was not clear enough.
Also, writing to FDs for /sys/class/pwm/ will most likely fail w/ this librobotcontrol lib. b/c of the fact that the PRU handles this subsystem for you or anyone else using this lib.
Phew and okay, I will keep trying. This lib. always interested me and I wanted to learn more but never had time.
Seth
P.S. You will need to use the PRUSS and that entails using the already configured PRUSS PWM usage on the BBBlue w/ librobotcontrol.
Now, the source may be a bit different but it allows for more am335x usage b/c of it offloading the the PRUSS. Off to keep trying! So, something like but different, i.e. as I have not perfected the art of source mfg. yet.
// Trying Out Some Source from LibRobotControl
// For debugging and testing w/ laasyapriya
// W/ some testing from Seth and some source from librobotcontrol theory...
#include <robotcontrol.h>
#include <stdio.h>
#define RC_SERVO_CH_MIN 1
#define RC_SERVO_CH_MAX 8
#define RC_ESC_DEFAULT_MIN_US 1000
#define RC_ESC_DEFAULT_MAX_US 2000
int main() {
int min_us = RC_ESC_DEFAULT_MIN_US;
int max_us = RC_ESC_DEFAULT_MAX_US;
int servo_pos 0.0;
double sweep_limit 1.0;
int ch 1;
double direction 1;
int frequency_hz 50;
int i, val;
}
// Main Loop at 50 Hz?
while(1) {
// increase and descrease?
servo_pos += direction * sweep_limit / frequency_hz;
// reset and start from scratch
if(servo_pos > sweep_limit) {
servo_pos = sweep_limit;
direction = -1.0;
}
else if(servo_pos < (-sweep_limit)) {
servo_pos = -sweep_limit;
direction = 1;
// The results are in...
}
}
// sleeping or trying to!
rc_usleep(50000 / frequency_hz);
break;
int rc_servo_init(void) {
// Start and Configure the PRU for sending Servo Pulses...
}
int rc_servo_power_rail_en(1) {
}
int rc_servo_set_esc_range(min_us, max_us) {
}
int rc_servo_send_pulse_us(1, 50) {
for(i = 1; i <= 8; i++) {
val = ch;
if(val > 0) {
rc_servo_send_pulse_us(i, val);
}
}
}
I will test this source and return service. Enjoy!
Okay, I am receiving some negative output so far but we can debug if necessary:
mark_one.c:15:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
15 | int servo_pos 1;
| ^
mark_one.c:16:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
16 | double sweep_limit 1.0;
| ^~~
mark_one.c:17:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
17 | int ch 1;
| ^
mark_one.c:18:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
18 | double direction 1;
| ^
mark_one.c:19:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
19 | int frequency_hz 50;
| ^~
mark_one.c:26:28: error: expected declaration specifiers or '...' before numeric constant
26 | int rc_servo_power_rail_en(1) {
| ^
mark_one.c:32:28: error: expected declaration specifiers or '...' before numeric constant
32 | int rc_servo_send_pulse_us(1, 50) {
| ^
mark_one.c:32:31: error: expected declaration specifiers or '...' before numeric constant
32 | int rc_servo_send_pulse_us(1, 50) {
| ^~
mark_one.c: In function 'main':
mark_one.c:45:3: error: 'servo_pos' undeclared (first use in this function)
45 | servo_pos += direction * sweep_limit / frequency_hz;
| ^~~~~~~~~
mark_one.c:45:3: note: each undeclared identifier is reported only once for each function it appears in
mark_one.c:45:16: error: 'direction' undeclared (first use in this function)
45 | servo_pos += direction * sweep_limit / frequency_hz;
| ^~~~~~~~~
mark_one.c:45:28: error: 'sweep_limit' undeclared (first use in this function)
45 | servo_pos += direction * sweep_limit / frequency_hz;
| ^~~~~~~~~~~
mark_one.c:45:42: error: 'frequency_hz' undeclared (first use in this function)
45 | servo_pos += direction * sweep_limit / frequency_hz;
| ^~~~~~~~~~~~
mark_one.c:61:2: error: break statement not within loop or switch
61 | break;
| ^~~~~
/usr/include/rc/servo.h: In function 'rc_servo_init':
mark_one.c:24:1: warning: control reaches end of non-void function [-Wreturn-type]
24 | }
| ^
/usr/include/rc/servo.h: In function 'rc_servo_set_esc_range':
mark_one.c:30:1: warning: control reaches end of non-void function [-Wreturn-type]
30 | }
| ^
make: *** [Makefile:36: mark_one.o] Error 1
That is from make clean && make
in the librobotcontrol/rc_project_template/
directory for my file I am trying to manage.