Pic Firmware
Forums:
Some questions concerning the pic firmware ..
Compilation on ubuntu works fine although it seems to be a windows
build because of a missing path in the <configurations.xml>:
<property key="tracecontrol.tracefile" value="C:\FRL\FRL Projects\NaffBorg\servo_and_usm\UltraBorg.X\defmplabxtrace.log"/>
Why is in the MPLABX Project
the PIC16F1828
choosen?
Is the code for a PIC16F1824 exactly the same?
Is the HEX File you push on the chip
done with the optimized XC8 compiler version?
Because with the free XC8 they say
"you could have produced up to 60% smaller and 400% faster code."
thanks for some info.
Bruce
piborg
Thu, 10/08/2015 - 18:48
Permalink
UltraBorg PIC code
You are correct, the final production build was done on a Windows machine.
The PIC fitted to the UltraBorg is a PIC16F1828, not a PIC16F1824.
The two PICs are basically the same, however the PIC16F1824 only has 14 pins, the PIC16F1828 has 20.
The extra pins provide some additional GPIO pins, which we needed for the UltraBorg design.
The builds have been performed with the free compiler.
We decided to do this so anyone who wants to modify the code can start from exactly the same build as we have.
Bruce
Thu, 10/08/2015 - 21:33
Permalink
PIC16F1824-I/SL -> PIC16F1828
On your UltraBorg Specification page you write about a PIC16F1824-I/SL
circuit. So possibly this needs an update.
Cheers.
piborg
Thu, 10/08/2015 - 22:17
Permalink
PIC16F1824-I/SL -> PIC16F1828-I/SS
Ah, that is a mistake, thanks for letting us know :)
We use the PIC16F1824-I/SL on the PicoBorg Reverse rather than the UltraBorg.
I have corrected the UltraBorg specification page to list the correct PIC now.
Bruce
Fri, 10/09/2015 - 14:32
Permalink
30Hz/60Hz/120Hz Servo operation .. ultasound port disable
Hello and thanks for the clarification,
now that I study the PicCode some questions rise about it.
You write that there is 30Hz/60Hz/120Hz Servo operation possible but preconfigured to 30Hz.
I can not directly find where in the PIC code these operation modes are configured.
SERVO_PULSE_CLOCK and SET_SERVO_SCLOCK seem the closest matches but
it does not pop up in my mind how these could be used to switch to i.e. 120Hz.
No where I cand find Hz.
Also the Ultrasound connectors fire continuously right?
There is no command to disable one connector for a while. Or is there?
So how or where would the servo frequency possibly be changed?
Thanks for some advice.
Greets
Andreas
piborg
Mon, 10/12/2015 - 11:25
Permalink
Changing the UltraBorg frequency
Changing the servo frequency involves a few code changes.
I will go through the changes needed below, they are not too obvious.
You are correct, the ultrasonic sensors are all triggered at a regular interval.
There is no command to disable any of the connectors.
The triggering and reading of the ultrasonic sensors is all handled by the
ReadAllUltrasonics
function inmain.c.
Changing the servo frequency
The servo output is generated from a clock signal output by the PIC.
This signal is linked to the internal clock.
To change it we need to alter a few places in the code.
The main change is to the
ConfigureOscillator
function in system.c.We need the clock to be at one of these speeds:
We also change the
PLLEN
setting in configuration_bits.c.#pragma config PLLEN = OFF // PLL Disable (4x PLL disabled)
#pragma config PLLEN = ON // PLL Enable (4x PLL enabled)
At this point the servos will operate at the correct speed, however the ultrasonic reading rate may be too fast.
We can fix this by changing the
main
function in main.c slightly.First add a counter variable inside
main
:Now modify the ultrasonic reading section to increase and check this counter:
Finally you will need to change the counter limit depending on the servo frequency:
if (usmTriggerCount >= 1) {
if (usmTriggerCount >= 2) {
if (usmTriggerCount >= 4) {
EagleParis
Thu, 09/10/2020 - 14:49
Permalink
Changing the UltraBorg PWM frequency to 20 KHz
Is it possible to reach 20KHz PWM frequency by reprogramming the PIC, or is it even possible after board initialisation to modify the frequency parameter through python (for driving a BLDC motor with integrated ESC)
piborg
Fri, 09/11/2020 - 09:44
Permalink
Unfortunately no
Unfortunately no. While the code could be changed to get higher frequencies, 20 KHz is beyond what UltraBorg would be capable of.