Difference between revisions of "ME333 Sample Code"
From Mech
Jump to navigationJump to searchNickMarchuk (talk | contribs) |
NickMarchuk (talk | contribs) |
||
Line 53: | Line 53: | ||
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s) |
* [[Media:NU32_stepper_example.c | NU32_stepper_example.c]]: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s) |
||
'''Controlling an RC servo motor'' |
'''Controlling an RC servo motor''' |
||
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins) |
* [[Media:NU32_rcservo_pwm_example.c|NU32_rcservo_pwm_example.c]]: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins) |
||
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo |
* [[Media:NU32_rcservo_digio_example.c|NU32_rcservo_digio_example.c]]: Use any digital IO pin and a timer to set the position of the servo |
Revision as of 11:48, 7 March 2012
Simple PIC
- simplePIC.c: Flashes LEDs on the NU32 unless the USER button is pressed.
NU32 library, header file, procdefs, and terminal comm test
- NU32.c: NU32 board library.
- NU32.h: NU32 header file.
- procdefs.ld: Linker file for NU32.
- NU32_serial_comm.c: Serial communication test with the terminal.
- NU32_serial_plot.c: Plot data with serial communication in NU32_Utility.
Analog to digital
- ADC_Read2.c: Reads two analog inputs repetitively and prints the results to the user's terminal.
- ADC_Read2_LCD.c Reads two analog inputs repetitively and prints the results to the LCD.
Digital I/O
- DIGIO_sfrs.c: Digital I/O and change notification using SFR manipulation.
- DIGIO_plib.c: Digital I/O and change notification using the peripheral library.
Interrupts
- INT_core_timer.c: Interrupt on core timer period match.
- INT_ext_int.c: Interrupt on rising edge of external interrupt line INT0.
LCD code
Output compare (PWM)
- OC_PWM_nolib.c: Set up PWM by setting SFRs.
- OC_PWM_lib.c: Set up PWM using peripheral library functions.
- OC_square_wave.c: Alternate between two different PWM duty cycles at 1 Hz. PWM is at 100 kHz and can be low-pass filtered to get a square wave analog output.
Counter/timer
- TMR_16bit.c: Set up a 16-bit timer to count the PBCLK.
- TMR_16bit_external_clocks.c: Count two external clock sources, such as the A and B channel from a motor encoder.
DSP and FFT
- DSP_sample_square_wave.zip: Examples of FIR and FFT in both MATLAB and on the PIC32.
- DSP_mips32_fft.zip: Example of using the Q31 mips library for FFT. Contains a C source file and a header file.
Reading a quadrature encoder with the dsPIC33FJ12MC201 breakout board
- NU32_dsPIC_QEI_example.c: Read the encoder count at 250Hz, send to the computer at 5Hz
Controlling a stepper motor with the TB6612
- NU32_stepper_example.c: Use the TB6612 to step the motor at 25 Hz steps (1 rev in 16s)
Controlling an RC servo motor
- NU32_rcservo_pwm_example.c: Use a PWM pin to set the position of the servo (note you only have 5 PWM pins)
- NU32_rcservo_digio_example.c: Use any digital IO pin and a timer to set the position of the servo