Search found 558 matches

by mnf
Mon Apr 06, 2020 4:48 pm
Forum: Flowcode V7
Topic: Counter not working in 16 bit
Replies: 6
Views: 65

Re: Counter not working in 16 bit

Something odd though -
since a left shift (<<8) is the 'same' as multiplying by 256.

Type error possibly - using a byte value might cause problems somewhere?

Martin
by mnf
Mon Apr 06, 2020 8:51 am
Forum: Flowcode V8
Topic: MFRC522 multible card/tag
Replies: 5
Views: 100

Re: MFRC522 multible card/tag

Hi Jorgen, No problem I'll do an example this evening... To muddy the water slightly - how about saving valid keys and names in the eeprom (or elewhere?) - this would allow you to update the list of allowed cards without reprogramming the device (however adding the names might be trickier?). Glad to...
by mnf
Sun Apr 05, 2020 10:16 pm
Forum: Flowcode V8
Topic: MFRC522 multible card/tag
Replies: 5
Views: 100

Re: MFRC522 multible card/tag

Hi Jorgen, How about using an array of long (unsigned) ints (conveniently the card ID is 4 bytes or 32 bits as per a long int) - Then it is an easy task to look through the 'ids' using a loop - and possibly have a second array of names to pull up the user 'name' So, say with have 10 ids and a corres...
by mnf
Sun Apr 05, 2020 9:47 pm
Forum: Flowcode V8
Topic: Non flowcode subject
Replies: 4
Views: 53

Re: Non flowcode subject

Hi Jan,

Yes, sorry to hear about the health issues. Enjoy getting back into Flowcode - a useful diversion in these difficult times. Any questions please post and I'm sure someone here will try and help!

Best wishes

Martin
by mnf
Sun Apr 05, 2020 10:13 am
Forum: General Programming
Topic: Embedded system ventilator
Replies: 10
Views: 114

Re: Embedded system ventilator

For home use - cpap machines are used and available to treat sleep apnea and provide air at 3-20hPa (for example) - note that I suspect oxygen would be added in a hospital setting. Home oxygen usually is regulated to 2 (or occasionally 4) l/min - from a cylinder or concentrator. Nebulized drugs woul...
by mnf
Sun Apr 05, 2020 5:47 am
Forum: General Programming
Topic: Embedded system ventilator
Replies: 10
Views: 114

Re: Embedded system ventilator

Yes, difficult times. I work as a pharmacist so have been extremely busy - panic 'buying' hasn't just applied to food. I'd say a ventilator isn't a good idea - you need to be heavily sedated - not something to try at home. Or encourage others to try. A team (Italian I think) has come up with an auto...
by mnf
Mon Mar 30, 2020 2:32 pm
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

Yes,
Use FCL_ as the prefix to the uppercase name ( instead of FCV_)

Martin
by mnf
Wed Mar 11, 2020 10:50 pm
Forum: Programming Tips & Tricks
Topic: WS2812 LED Flexible 32 x 8 grid
Replies: 15
Views: 2701

Re: WS2812 LED Flexible 32 x 8 grid

Another use for a WS2812 chip... Not really much Flowcode here - but hopefully someone will find the idea useful (hopefully some FC to come later :-) ) - wanted to create a simple puzzle game using illuminated push buttons that can change colour... However apart from some three colour buttons (with ...
by mnf
Mon Mar 02, 2020 10:09 am
Forum: General Programming
Topic: storing data in memory
Replies: 6
Views: 324

Re: storing data in memory

Writes are not 'atomic' (to use a database analogy) - however, if the data is only written occasionally the risk of corruption is be pretty small.. For example 'ignition turned off' (5s capacitor power available) - write data. Read on startup... It depends how 'mission critical' the data is too? Mar...
by mnf
Mon Mar 02, 2020 8:35 am
Forum: General Programming
Topic: storing data in memory
Replies: 6
Views: 324

Re: storing data in memory

Also take a look at using the eeprom in the mcu. You can store up to 1024 bytes on the atmega328 and these values survive power 'cuts '. The memory has a limited number of write cycles (100000)- so don't write the value too often and always read the value and check if the new value is different befo...
by mnf
Sun Feb 09, 2020 5:41 pm
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 12
Views: 711

Re: Atmega8 Series Sleep mode and Watchdog Timers

Hi Sadik, I created a simple wdt example - note I use an Arduino Nano (and flash the inbuilt led on B5) I use a custom interrupt handler to set up the wdt and a handler (an empty macro) - not sure on the code to disable the interrupt, so have left this as an exercise... Try on Atmega8 - hopefully wi...
by mnf
Sun Feb 09, 2020 5:40 am
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

You can just assign the value.. .f32 = .f64 should work although you might need a cast. In a C block - FCL_F32 = (float) FCL_F64; However - if FC is defining a float as 64 bit you might struggle with your definitions? Pulling the exponent and mantissa from the byte values would by tricky. See https:...
by mnf
Sat Feb 08, 2020 10:39 pm
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

So - you want to convert the value to a 32bit integer (rather than a 32bit float)? What range of values are you working with and how many points of accuracy do you need? Taking the byte 'values' of the fp number isn't the way to go here (it would be possible - but difficult) Could you - for example ...
by mnf
Sat Feb 08, 2020 8:27 pm
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

If they are 64 bit then change byte array to 8 bytes (and the loop in FloatToByte)

If the values are 32 bit the last 4 bytes will be junk...

Martin
by mnf
Sat Feb 08, 2020 8:11 pm
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

Hi Kisen,

Try this - works AOK on Arduino and hopefully on ARM too....

Note the reversal of the bytes in FloatToByte...

float_to_byte.fcfx
(12.39 KiB) Downloaded 14 times


Note - if the floats are 64bit) - then extend the byte array to 8 bytes. If it is only 32bit then the last 4 bytes may be 'random' data

Martin
by mnf
Mon Feb 03, 2020 8:00 pm
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 12
Views: 711

Re: Atmega8 Series Sleep mode OK, So how do I wake up this processor?

I had a brief play with your code - and compiling for ATMega8 - gave a hex too large (by 3k!) using FC8 I fixed this by changing the optimisation of the compiler from the FC default to the maximum for gcc. (This requires editing avra.bat (in C:\Program Files (x86)\Flowcode\Common\Compilers\avr\batch...
by mnf
Mon Feb 03, 2020 9:59 am
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 12
Views: 711

Re: Atmega8 Series Sleep mode OK, So how do I wake up this processor?

Hi Sadik, Will take a peek after work (though, with the helpful folk on the forum, you may have an answer by then :) )... In the meantime - can the RFID reader generate an interrupt on card present? If so - could this wake the processor. (A a quick glance at the datasheet didn't reveal one - generat...
by mnf
Mon Feb 03, 2020 2:41 am
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 12
Views: 711

Re: Atmega8 Series Sleep mode OK, So how do I wake up this processor?

Hi Sadik,

What sleep level are you using? Wake can be on interrupt (say rx or WDT or external) - can you post a snippet of code?

Martin
by mnf
Sun Feb 02, 2020 11:44 pm
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 12
Views: 711

Re: Atmega8 Series Sleep mode

Hi Sadik,

You'll need a (in a C block or Supplementary code)

Code: Select all

#include <avr/sleep.h>


and then use

Code: Select all

sleep_enable();
sei();
sleep_cpu();


See https://www.microchip.com/webdoc/AVRLibcReferenceManual/group__avr__sleep.html

Martin
by mnf
Tue Jan 28, 2020 9:42 pm
Forum: General Programming
Topic: FLOAT to INT and back again.
Replies: 33
Views: 1169

Re: FLOAT to INT and back again.

See this thread viewtopic.php?f=7&t=21470&hilit=float where a different approach is used (taking the address of the number and writing/reading the value)

But, please, can you post your code that is not working?

Martin
by mnf
Mon Jan 27, 2020 8:26 pm
Forum: Flowcode V8
Topic: Not able to program a MEGA 2560 R3
Replies: 6
Views: 399

Re: Not able to program a MEGA 2560 R3

See https://www.matrixtsl.com/flowcode/buy/5.php (you will need to login) - the Arduino pack contains what you need.. If you already own it - in FC - Help -> Manage Licences -> My Licences. Enter your Matrix username (not forum name) and click Activate. It will prompt for password and should reinsta...
by mnf
Mon Jan 27, 2020 6:54 pm
Forum: Flowcode V8
Topic: Not able to program a MEGA 2560 R3
Replies: 6
Views: 399

Re: Not able to program a MEGA 2560 R3

It doesn't look like the relevant 'chip' pack is enabled. Unfortunately - the Mega2560 isn't one of the free targets..
If you do have a licence - try re-enabling the licence (I few days ago - I suddenly got the same message - and doing this restored things to order)

Martin
by mnf
Fri Jan 24, 2020 8:16 pm
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 799

Re: Byte in HEX format

The lsb byte shows low to very high wind speed values. I can use this lsb byte data (as 26 only) or I can use: wind_speed_new = (00 << 8 ) + 26 the result is the same: 26. I'd create a macro to read 16 bit value - that can work with wind speed /baud rate etc - 0 * 256 does (of course) = 0 but you d...
by mnf
Fri Jan 24, 2020 3:53 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 799

Re: Byte in HEX format

To give an example from the manual - first I read (and it is 2:40am here :( ) is baud rate is returned as 25 80 = 9600 baud Which is indeed true - the sensor returns a 16 bit binary value which you can display as 25 80, 9600 or 00101001 1000000 - but the only conversion needed is when you display th...
by mnf
Fri Jan 24, 2020 3:35 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 799

Re: Byte in HEX format

Hi Viktor, I still think this is a misunderstanding as to what the sensor sends - it looks to me like it sends a 16 bit number as msb then lsb. (So ws = (b1 << 8 ) + b2) where b1 is first data byte read and b2 second. Try printing the actual value received using SendNumber(ws) and SendString (number...