Page 1 of 3
MIAC-RC LawnMower
Posted: Sun May 21, 2017 7:11 pm
by Monie Jacobsen
User Type Device: MAC (Arduino) MI5466
Used for motor control for LawnMower.
The code below works:
But try convert to MIAC (Arduino) MI5466 but do not work.
See below:
Is there anyone here that can see where things are going wrong.
Hope someone here will help solve the problem.
Re: MIAC-RC LawnMower
Posted: Sun May 21, 2017 7:53 pm
by Steve001
would love to see that when it's finished
Steve
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 10:12 am
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 ?
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 10:57 am
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.
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 11:58 am
by Monie Jacobsen
Thank you very much LeighM.
Have worked a lot about the problem;)
Please see attached File:
Voltage range I have input MIAC inputs.
0.878 Vdc to 1.003 Vdc
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 12:58 pm
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 (14.17 KiB) Viewed 20804 times
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 1:39 pm
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?
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 1:46 pm
by LeighM
What is the circuit that supplies voltage into the MIAC input?
The MIAC has an input resistance of 10K
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 4:29 pm
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 (25.59 KiB) Viewed 20797 times
manual for FS-R9B
https://www.aliexpress.com/store/produc ... 55869.html
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 5:19 pm
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
Re: MIAC-RC LawnMower
Posted: Mon May 22, 2017 6:43 pm
by Monie Jacobsen
Hi LeighM
Thank you very much for your help.
I want to work on my project
Re: MIAC-RC LawnMower
Posted: Tue May 23, 2017 7:53 am
by Monie Jacobsen
Hi LeighM
Trying to use dsPIC .Type MI5809
But now the interrupt not will work!
See attached code:
Do you have a suggestion?
Re: MIAC-RC LawnMower
Posted: Tue May 23, 2017 8:43 am
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
Re: MIAC-RC LawnMower
Posted: Tue May 23, 2017 9:19 am
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.flowcode.co.uk
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
Re: MIAC-RC LawnMower
Posted: Tue May 23, 2017 9:31 am
by LeighM
Hi,
You can remove your Reset timer C icon, it should be TMR1 and this is reset in the Interrupt Enable ...
And the last one after the Interrupt Disable should be ...
Re: MIAC-RC LawnMower
Posted: Tue May 23, 2017 10:55 am
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.
Re: MIAC-RC LawnMower
Posted: Tue May 30, 2017 12:07 pm
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 (3.99 KiB) Viewed 20612 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 (18.99 KiB) Viewed 20614 times
Result shown in display from dsPIC .Type MI5809.
See ouput below:
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
Re: MIAC-RC LawnMower
Posted: Tue May 30, 2017 3:08 pm
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.
Re: MIAC-RC LawnMower
Posted: Tue May 30, 2017 4:31 pm
by Monie Jacobsen
Hi LeighM
Have tried but no luck

Please see the following update file:
Is that what you mean?
I'm not sure what you mean!
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 11:33 am
by LeighM
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 12:21 pm
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?
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 12:40 pm
by LeighM
Looks like we have an overflow on a variable
try this ...
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 2:07 pm
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
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 2:44 pm
by LeighM
Can you get some more values (of tsum and the servo) between the two limits, 800 (3523) and 2200 (1517)
Re: MIAC-RC LawnMower
Posted: Wed May 31, 2017 3:20 pm
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)