Search found 548 matches

by mnf
Sun Feb 09, 2020 5:41 pm
Forum: Flowcode V8
Topic: Atmega8 Series Sleep mode and Watchdog Timers
Replies: 9
Views: 235

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: 31
Views: 514

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: 31
Views: 514

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: 31
Views: 514

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: 31
Views: 514

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 3 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: 9
Views: 235

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: 9
Views: 235

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: 9
Views: 235

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: 9
Views: 235

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: 31
Views: 514

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: 182

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: 182

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: 477

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: 477

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: 477

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...
by mnf
Thu Jan 23, 2020 11:21 pm
Forum: Flowcode V8
Topic: Leading a workshop for Flowcode
Replies: 5
Views: 203

Re: Leading a workshop for Flowcode

Good luck.

You're most welcome to use any of the code snippets I've posted over the last couple of years - some of them are even commented :D

Martin
by mnf
Thu Jan 23, 2020 11:02 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 477

Re: Byte in HEX format

There is nothing to convert! Hex(26) is exactly the same as decimal(38) - no conversion necessary...
by mnf
Thu Jan 23, 2020 10:27 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 477

Re: Byte in HEX format

If it returns 26 you don't need to do anything - it is the same as 38 decimal... Just use the value - and all will be well. You'll need to move the MSB to the upper 8 bits if it's 16 bits. This is just a human readable representation (in the manual too) of the number - it gets converted to this form...
by mnf
Thu Jan 23, 2020 9:14 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 477

Re: Byte in HEX format

Need to check what the sensor is returning. It is probably an 8 or 16 but number - and already in av format you can use. Ifv it is sending a string (unlikely) them you'll need to convert it to a number (a string it's a human form if the number using ascii ) The 0x is just a convention that tells the...
by mnf
Thu Jan 23, 2020 2:17 am
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 477

Re: Byte in HEX format

Yes. The values 0x26 or 38 are just representations of the number in base 16 or base 10. The number is held as 8,16 or 32 bits binary (base 2) and just converted to a readable form when displayed or converted to a string. Numbers are also converted to the machine form by the compiler... What number ...
by mnf
Wed Jan 22, 2020 10:47 pm
Forum: General Programming
Topic: YGC-FS wind speed sensor data: HEX or decimal?
Replies: 16
Views: 477

Re: Byte in HEX format

The byte value is the same - 0x26 = 38 which are just the human readable forms of the underlying value.

So yes you can do x = 0x26 + 10 or x = 38 + 0x0a and the results will be as expected.

Martin
by mnf
Wed Jan 22, 2020 6:51 pm
Forum: General Programming
Topic: VISI display advice and guidence.
Replies: 7
Views: 239

Re: VISI display advice and guidence.

FC allows arrays - with a syntax very similar to C... So when creating a variable - add the number of elements for the array in square brackets after the variable name... array.JPG To declare an array of 10 bytes.. Note that to access them arrays are 0 based (so x[0] .. x[9] here) Using a loop - use...
by mnf
Wed Jan 22, 2020 6:22 pm
Forum: Bug Reports
Topic: Bad mistake in FC8!
Replies: 40
Views: 2513

Re: Bad mistake in FC8!

I can fairly reliably replicate this error on my laptop - Windows 10 (fully updated) The specific task - expose properties from a component to top level (in this cases SDA/SCL from cal_12c) Then 'drag' them into position on the panel properties (this for a component...) - I first dragged one to bott...
by mnf
Tue Jan 21, 2020 6:59 pm
Forum: General Programming
Topic: VISI display advice and guidence.
Replies: 7
Views: 239

Re: VISI display advice and guidence.

Hi Chris,

If using Flowcode then use an array on the first instance. You can do linked lists - but it needs a bit of C to work properly. Can you post some snippets of code or pseudocode showing what you need to do?

Martin
by mnf
Tue Jan 21, 2020 2:19 pm
Forum: General Programming
Topic: VISI display advice and guidence.
Replies: 7
Views: 239

Re: VISI display advice and guidence.

Arrays would probably be the way to go here... You could use a linked list but I'm not sure it would be worth the extra code - the memory savings would be negligible. So it is easy to have int X[24]; or a 2 dimensional array to cover all 4 displays And to iterate over using a loop for (i = 0; i < 24...