printf to display pwm outputs?

I know this is a really stupid question, but to be honest I never use printf regularly so I don’t know how to use it. I want a simple printf to display what voltage pwm9 and pwm10 at outputting to the camera (or really, one of our mentors is requesting it to help with testing our camera issues). Can anyone help with this?

Assuming that you are using Servo objects to control the camera motors, you can’t get the voltage going to the servos on the camera. Servos don’t take analog input to move (in a sense). Instead, they take PWM to turn to a specific angle depending on the pulsewidth of the signal sent. So finding the voltage being sent won’t really help you. You can use this code though to get the angle being sent to the servo:

printf("1: %f , 2: %f
", servo1->GetAngle(), servo2->GetAngle());

Make sure you have the setup required to get debug output from the cRio. This means making a physical connection to the cRio via serial cable and making sure the little “debug” switch on the cRio is in the on position.

Thanks for the help, this could be just what we need to finally trace the issue with our camera :slight_smile:

Ummm, just a quick note, contrary to what the documentation says, you do not need the serial cable to use the console. By going in to the remote systems tab, right clicking the connection to the cRio>something tools(don’t remember right now)>console you can get a console to the robot without a serial cable. I think you might need to have the dip switch on the robot set to display console though. I haven’t tried with the dip switch off.

Thxe

We’ve ran into performance issues when using printf, which haven’t been particularly consistent. As a rule of thumb, you don’t want to printf too many times per second (we’ve found 4 to 10 works with varying results).