Search found 1013 matches

by mnf
Tue Jan 11, 2022 11:54 am
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Yes...
by mnf
Tue Jan 11, 2022 8:06 am
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

I'm hoping so - unfortunately I don't have a PIC licence under v8 to test. However, i 've not used any v9 specific features.. I do have some PIC hardware which I can try - although it will be tomorrow before I get a chance. It is a direct translation of the program given - try changing the target - ...
by mnf
Mon Jan 10, 2022 10:38 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

So - first, a literal translation.

However, all I can say for sure is that it compiles.... Under v9...

Perhaps you could test and see if there is any output? Note that the interrupt setting might need some adjustment depending on the clock you have..
by mnf
Sun Jan 09, 2022 4:35 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

I found some (partial) PIC code at https://microcontrollerslab.com/complet ... -inverter/ - he requests $40 for the complete code...
However, there may be enough clues there to give us a start.

Martin
by mnf
Sun Jan 09, 2022 2:01 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

It won't be easy to convert :cry: Any PIC folk any ideas - the code generates a sine wave over two pins with x = time and y = length of pulse. The 'negative' y values are a mirror on the second pin. The code seems to work well - but it's very AVR specific (uses the PWM to generate the pulses..) I us...
by mnf
Sun Jan 09, 2022 6:54 am
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Hi. No problem - it should compile under v8 okay. Converting it to pi.c won't be easy though - all the register writes are very AVR specific - the pic will have similar capabilities but you are probably best starting from scratch or swapping mcu - it will work with some minor modification on various...
by mnf
Sat Jan 08, 2022 6:54 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Okay - so a first attempt which seems to work okay.. Unfortunately the C is written in 'write only' or 'write once' style (no comments) - so I haven't tried to decipher the register writes. This is left as an exercise. It would possibly be okay just to use a standard FC timer interrupt setup - but I...
by mnf
Fri Jan 07, 2022 6:55 am
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Hi, no, it could work - just that I think the C code has a bug in it. So as the joke goes - how do you get to... Well I wouldn't start from here. I'll have a play over the weekend and set it I can get a version working... Some compilers would optimise tail-recursion to a jump but i don't think they ...
by mnf
Thu Jan 06, 2022 10:43 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

The code can be converted to Flowcode - with the proviso that a fair amount will remain as C (all the register assignments such as TCCR1A = ... for example) However - I think it will eventually crash (in C or FC) - the function Inverter is recursive (it calls itself in two places with no return) and...
by mnf
Wed Oct 20, 2021 11:54 am
Forum: General Programming
Topic: Storing long negative numbers in EEPROM
Replies: 15
Views: 12414

Re: Storing long negative numbers in EEPROM

Hi Abhi, Just on my phone at moment - so can't test... I would suggest making a loop to read and write values (as separate macros) So in pseudocode: for .i = 0..3 Write (.i +addr, .n) // Writes LSB .n = .n >> 8 // shift next byte into LSB end loop The addr variable allows writing to other than 0... ...
by mnf
Wed Oct 20, 2021 11:00 am
Forum: General Programming
Topic: Storing long negative numbers in EEPROM
Replies: 15
Views: 12414

Re: Storing long negative numbers in EEPROM

Hi Abhi,

Can you post your code - I would guess the bytes are getting reversed in the process because the technique looks ok..

Martin
by mnf
Wed Oct 20, 2021 3:40 am
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Just realised, at daft o'clock in the morning, that the code above will only work on v9 Flowcode I use an array initialised in the variable definition. It would be easy to modify to use a look up component. It also doesn't use any components and will work on the free version of v9. If needed I can d...
by mnf
Tue Oct 19, 2021 9:13 pm
Forum: Flowcode V8
Topic: Pure Sine Wave Inverter
Replies: 38
Views: 40417

Re: Pure Sine Wave Inverter

Hi, Not sure if this got sorted - or even if this will be useful... However - the current project I'm working on needs a wave generator - not necessarily sine, however my code was easily modified to do this. I'm using a discrete DAC (a MCP4725) - and (hopefully will be) feeding the output into an op...
by mnf
Thu Oct 14, 2021 12:52 pm
Forum: Flowcode V8
Topic: ADC NOISE REDUCTION in AVR
Replies: 10
Views: 4564

Re: ADC NOISE REDUCTION in AVR

You can set bits in the registers using a C block to set use | (or) and to clear use & (and) in this case to set SM2 to SMO to 0b001 (binary) MCUCR = MCUCR & 0b10001111; // Clear SM2 to SM0 MCUCR = MCUCR | 0b10000; // Set SM0 to 1 In the real world these would probably be combined into one line: MCU...
by mnf
Sun Oct 03, 2021 1:46 pm
Forum: Flowcode V8
Topic: Read Passing Second from RTC
Replies: 6
Views: 2498

Re: Read Passing Second from RTC

Glad to hear it worked - especially with the connection to the chip being necessary - I'm not sure my soldering skills would cope with that!

Martin
by mnf
Sun Oct 03, 2021 12:18 pm
Forum: Flowcode V8
Topic: Read Passing Second from RTC
Replies: 6
Views: 2498

Re: Read Passing Second from RTC

Hi Abhi, A simple example - I used an Arduino Nano (and then I can plug my RTC module in on pin A2-A7 and power the RTC using A2 and A3 - you can remove the setup (output to A2 and A3) if you use a different power mode). Note - I used the Ds3231 component from https://www.matrixtsl.com/mmforums/view...
by mnf
Sun Oct 03, 2021 11:03 am
Forum: Flowcode V8
Topic: Read Passing Second from RTC
Replies: 6
Views: 2498

Re: Read Passing Second from RTC

Hi Abhi,

The RTC can generate a 1s pulse - use this to generate an interrupt - and take a reading then.

Martin
by mnf
Thu Sep 16, 2021 12:54 pm
Forum: General Programming
Topic: Problems Using Interrupts on Atmega88
Replies: 5
Views: 6243

Re: Problems Using Interrupts on Atmega88

No problem - glad it worked... I'd misread your post as ATTiny88 :roll:

The principle should be the same though.....
by mnf
Wed Sep 15, 2021 6:56 pm
Forum: General Programming
Topic: Problems Using Interrupts on Atmega88
Replies: 5
Views: 6243

Re: Problems Using Interrupts on Atmega88

Here is a blinkie using interrupt... On the ATTiny board I have the power LED (green) is too bright and the 'test' LED (red) is outshone... You might also need to adjust the clock speed - here it's 8MHz (the HW-Tiny boards run at 12MHz - if that's what you are using?) I used a USBTiny programmer... ...
by mnf
Wed Sep 15, 2021 6:26 pm
Forum: General Programming
Topic: Problems Using Interrupts on Atmega88
Replies: 5
Views: 6243

Re: Problems Using Interrupts on Atmega88

Hi Oderlando, I think you are trying to be too 'precise' on the comparisons - if clock = 1 (which might get caught on the first loop) and if clock = 7800 (which is very unlikely to ever get a hit) You need to check for a 'range' - so for example (if clock > 1000 and clock < 5000) You also have delay...
by mnf
Tue Sep 14, 2021 3:58 pm
Forum: Flowcode V8
Topic: 16Bit ADC chip
Replies: 15
Views: 7976

Re: 16Bit ADC chip

Credit where it's due.

- that is Peter's hard work....

Need to get back and do some more programming - after a long lazy (enforced) summer....

Martin
by mnf
Sun Aug 29, 2021 9:39 pm
Forum: General Programming
Topic: HOW PRECISE IS PWM
Replies: 6
Views: 8093

Re: HOW PRECISE IS PWM

I did this: (a while ago)
freq2.fcfx
(16.96 KiB) Downloaded 197 times
That did a frequency sweep (on a pic16lf1513) and the output looked good on a scope... Approx 15Hz steps.

Martin
by mnf
Sun Aug 29, 2021 7:02 pm
Forum: General Programming
Topic: HOW PRECISE IS PWM
Replies: 6
Views: 8093

Re: HOW PRECISE IS PWM

Yes, PWM has a number of discrete steps - each of a number of Hz... For example 10 bit resolution will give 1024 steps over the PWM range. The PIC documentation gives the following on 'PWM 'resolution IMG_20210829_185338.jpg (sorry had to photo the page here - for better reading download from microc...
by mnf
Wed Aug 25, 2021 11:59 pm
Forum: Flowcode V8
Topic: AVERAGE FLOATING POINT
Replies: 6
Views: 2136

Re: AVERAGE FLOATING POINT

No problem, hope it is useful

If speed is important then make the sum global and subtract the existing value (buffer[pos]) before adding the new value... Then you can remove the loop too...

Math
by mnf
Wed Aug 25, 2021 9:58 pm
Forum: Flowcode V8
Topic: AVERAGE FLOATING POINT
Replies: 6
Views: 2136

Re: AVERAGE FLOATING POINT

Here's an example using a FIFO list of data (just random data here...)
fifo.fcfx
(12.69 KiB) Downloaded 143 times
The macro AddValue does all the work - main just pumps in data and displays debug to UART (with a lomg delay that could be reduced for simulation...)

Martin