MIAC-RC LawnMower

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

MIAC-RC LawnMower

Post by Monie Jacobsen »

User Type Device: MAC (Arduino) MI5466
Used for motor control for LawnMower.

The code below works:
PulseTiming-Mega2560-I2C.fcfx
(16.85 KiB) Downloaded 333 times
But try convert to MIAC (Arduino) MI5466 but do not work.
See below:
MIAC-LawnMower.fcfx
(18.07 KiB) Downloaded 323 times
Is there anyone here that can see where things are going wrong.
Hope someone here will help solve the problem.
Best Regard
Monie

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: MIAC-RC LawnMower

Post by Steve001 »

would love to see that when it's finished :mrgreen:

Steve
Success always occurs in private and failure in full view.

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Can PulsTiming work in MAC (Arduino) MI5466 Like MEGA 2560 ?
And what should be changed in the coder so that PulsTiming can work with MAC ?
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Hi Monie,

In the "while sw = 1" loops you need to change the InputANALOG() into InputDIGITAL()
Or change the compare value to your own threshold, e.g. while sw > 128
The value will depend on what range of voltage you have into the MIAC inputs.

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Thank you very much LeighM.
Have worked a lot about the problem;)
Please see attached File:
MIAC-LawnMower-001.fcfx
(19.28 KiB) Downloaded 328 times

Voltage range I have input MIAC inputs.
0.878 Vdc to 1.003 Vdc
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Hi Monie,
If your MIAC input high voltage is between 0.878 Vdc to 1.003 Vdc then it will not be high enough to trigger a logic high.
Have a look at the conversion chart on page 18 of the MIAC datasheet.
In this case you will need to use the InputANALOG() which will return a value of about 20 for an input of 1 Volt.
So if your input voltage is 0v for off and about 1v for on, then I suggest you test for values above and below a threshold of about 10...
MIAC_Analog_Input.jpg
MIAC_Analog_Input.jpg (14.17 KiB) Viewed 18983 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM,
Have tried your suggestion but enter resultal, only "0" is displayed.
So right now I do not know what to do!
What do you say to convert ouput up?
Can this be used or is something I can not
Else how much should I convert?
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

What is the circuit that supplies voltage into the MIAC input?
The MIAC has an input resistance of 10K

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM

Is it the device below which supplies voltage to MIAC input?
Remote control system
Receiver type FS-R9B
FS-R9B.jpg
FS-R9B.jpg (25.59 KiB) Viewed 18976 times
manual for FS-R9B
https://www.aliexpress.com/store/produc ... 55869.html
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Ah, I see, I missed the fact that you are using an RC servo system.
You would need to use MIAC Inputs 1 and 2 as direct digital inputs with InputDIGITAL(),
only these two inputs connect directly to digital inputs on the processor.
The InputANALOG() will be too slow.
The next problem is that the RC receiver channel outputs will not be a high enough voltage,
so you will need to level shift from the RC logic level to the MIAC level,
something like this should do it ...
https://www.onsemi.com/pub/Collateral/MC14504B-D.PDF

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM

Thank you very much for your help.
I want to work on my project
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
Trying to use dsPIC .Type MI5809
But now the interrupt not will work!
See attached code:
MIACdsPIC-LawnMower.fcfx
(19.33 KiB) Downloaded 300 times
Do you have a suggestion?
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Hi,
I have made some changes in CH2 macro, you still had a test for sw < 20 for the digital return.
Hope that helps.
Leigh
Attachments
MIACdsPIC-LawnMower.fcfx
(19.13 KiB) Downloaded 208 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
Received notification when trying to upload at Interrupt error
See compiler messages below!

Code: Select all

Target folder: C:\Users\Bruger\Desktop\MIACTI~1
Source name:   C:\Users\Bruger\Desktop\MIAC til FLOWCODE FORUM\MIACdsPIC-LawnMower.fcfx
Title:         
Description:   
Device:        PIC16.33E.MIAC (dsPIC)
Generated by:  Flowcode v7.2.1.4
Date:          Tuesday, May 23, 2017 10:01:10
Users:         1
Registered to: monie jacobsen
Licence key:   YUWNEC
http://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic16\batchfiles\pic16_C30_comp.bat  "MIACdsPIC-LawnMower" "C:\Users\Bruger\Desktop\MIACTI~1\" "33EP256MU806"
Launching compiler...

C:\Users\Bruger\Desktop\MIACTI~1>xc16-gcc -c -mcpu="33EP256MU806" -omf=coff -funsigned-char -fno-short-double -Os -I"C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic16\BATCHF~1\..\support\h" -I"C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic16\BATCHF~1\" -std=gnu99 "MIACdsPIC-LawnMower".c -o "MIACdsPIC-LawnMower".o 
Options have been disabled due to restricted license
Visit http://www.microchip.com/ to purchase a new key.
MIACdsPIC-LawnMower.c: In function 'FCM_CH2':
MIACdsPIC-LawnMower.c:1392:2: error: 'TCNT0' undeclared (first use in this function)
MIACdsPIC-LawnMower.c:1392:2: note: each undeclared identifier is reported only once for each function it appears in

Error returned from [xc16-gcc.exe]
Completed compilation, return = 1

C:\Program Files (x86)\Flowcode 7\compilers\pic16\batchfiles\pic16_C30_comp.bat reported error code 1



FINISHED
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Hi,
You can remove your Reset timer C icon, it should be TMR1 and this is reset in the Interrupt Enable ...

Code: Select all

// TCNT0 = 0;
And the last one after the Interrupt Disable should be ...

Code: Select all

FCV_TSUM = TMR1;

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi Leigh
Thank you for your great help.
Now I can upload code to dsPIC.
I try to convert Receiver type FS-R9B output signal up.
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
I have now got the RC logic level to the MIAC.
The converted RC outputs 4V to 12V according to the oscilloscope.
5v-to-12v-logic-level-shifter.gif
5v-to-12v-logic-level-shifter.gif (3.99 KiB) Viewed 18791 times
But in dsPIC. Type MI5809 does not show the correct ouput for display that should be 0- 255 bit
User RC-Servo Test:
RC-Servo-Test.JPG
RC-Servo-Test.JPG (18.99 KiB) Viewed 18793 times
Result shown in display from dsPIC .Type MI5809.
See ouput below:
MIACdsPIC-LawnMower-003.fcfx
(18.78 KiB) Downloaded 227 times
By from RC servo is 800 til 2200 Pulse
Has attached the FlowCodes below:
Servo: Output display:
800 - 255 bit
935 - 0 bit
1147 - 30 bit
1351 - 194 bit
1827 - 255 bit
1930 - 0 bit

But want Output for display from 0 to 255 bit

Can you see the codes where it goes wrong:
I would be very happy for your help
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Perhaps you could display the tsum value before (and after) the Map, also use an (additional) different variable for the output of Map.
Then you will be able to see the raw timer values that the MIAC uses, and then adjust the min and max parameter values of Map to match the MIAC ones.

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
Have tried but no luck ;-)
Please see the following update file:
MIACdsPIC-LawnMower-004.fcfx
(20.03 KiB) Downloaded 255 times
Is that what you mean?
I'm not sure what you mean!
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Try this ....
MIACdsPIC-LawnMower-005.fcfx
(19.2 KiB) Downloaded 231 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
Result from practice driving with RC servo tests

Ouput from RC servo is 800
Displayed in display:
MAP value = 255
TSUM value = 3523

Ouput from RC servo is 2200
Displayed in display MAP value = 130
TSUM value = 1517

Servo: Output display should be:
800 - 0 bit
2200 - 255 bit
What should be done to show this result?
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Looks like we have an overflow on a variable
try this ...
MIACdsPIC-LawnMower-006.fcfx
(19.2 KiB) Downloaded 245 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM
Thank you for your suggestion but it did not change the result on the output display.
OK with overflow on a variable.
Ouput speech has not changed.
MAP value is still as from last post
TSUM value is still as from last post
Best Regard
Monie

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MIAC-RC LawnMower

Post by LeighM »

Can you get some more values (of tsum and the servo) between the two limits, 800 (3523) and 2200 (1517)

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: MIAC-RC LawnMower

Post by Monie Jacobsen »

Hi LeighM

Servo: Output display:
800 - 255 bit
935 - 0 bit
1147 - 30 bit
1351 - 194 bit
1827 - 255 bit
1930 - 0 bit
I can not get some more values (of tsum and the servo) between the two limits, 800 (3523) and 2200 (1517)
Last edited by Monie Jacobsen on Fri Jun 02, 2017 4:33 pm, edited 2 times in total.
Best Regard
Monie

Post Reply