working so far
This commit is contained in:
parent
8a3d721314
commit
8c9151a143
Binary file not shown.
@ -13,19 +13,29 @@
|
||||
|
||||
#include "inverter.h"
|
||||
|
||||
#define NUM_OF_SINE_VALUES 10
|
||||
#define NUM_OF_SINE_VALUES 20
|
||||
|
||||
float sineValues[NUM_OF_SINE_VALUES] = {
|
||||
0.1564,
|
||||
0.3090,
|
||||
0.4540,
|
||||
0.5878,
|
||||
0.7071,
|
||||
0.8090,
|
||||
0.8910,
|
||||
0.9511,
|
||||
0.9877,
|
||||
1.0000,
|
||||
0.9877,
|
||||
0.9511,
|
||||
0.8910,
|
||||
0.8090,
|
||||
0.7071,
|
||||
0.5878,
|
||||
0.4540,
|
||||
0.3090,
|
||||
0.0000,
|
||||
0.1564,
|
||||
0.0000
|
||||
};
|
||||
|
||||
volatile uint16_t pulseWidths[NUM_OF_SINE_VALUES * 2] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
@ -72,7 +82,7 @@ void inverterInit() {
|
||||
P2DIR |= BIT0;
|
||||
P2SEL |= BIT0;
|
||||
|
||||
TA1CTL = MC_1 | ID_1 | TASSEL_2 | TACLR;
|
||||
TA1CTL = MC_1 | ID_0 | TASSEL_2 | TACLR;
|
||||
TA1CCTL0 = CCIE | OUTMOD_4;
|
||||
TA1CCTL1 = CCIE;
|
||||
TA1CCR0 = 0;
|
||||
@ -81,13 +91,13 @@ void inverterInit() {
|
||||
|
||||
void inverterSetFrequency(uint16_t f) {
|
||||
float ff = (float)f;
|
||||
float slotLength = 100.0 / (ff * 9.8e-6 * 20);
|
||||
float slotLength = 2 / (ff * 200e-9 * NUM_OF_SINE_VALUES);
|
||||
uint16_t sl = (uint16_t)slotLength;
|
||||
|
||||
uint8_t currentOffset = (activeOffset == 0) ? NUM_OF_SINE_VALUES : 0;
|
||||
for (uint8_t i = 0; i < NUM_OF_SINE_VALUES; i++) {
|
||||
uint16_t pw = (uint16_t)(slotLength * sineValues[i]);
|
||||
pulseWidths[i + currentOffset] = (pw == sl) ? (pw - 5) : pw;
|
||||
pulseWidths[i + currentOffset] = (pw == sl) ? (pw - 15) : pw;
|
||||
}
|
||||
|
||||
__disable_interrupt();
|
||||
|
@ -30,7 +30,7 @@ int main() {
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
inverterSetFrequency(100);
|
||||
inverterSetFrequency(75);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user