IOC dilema

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Lord Grezington
Flowcode V4 User
Posts: 233
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 18 times
Been thanked: 25 times
Contact:

IOC dilema

Postby Lord Grezington » Fri Sep 13, 2019 2:54 pm

Hello All

There is a part of a program (in FC8) on a 16F18344 where all I am doing is using an IOC pin (C2) which just has few pulses coming in. All I am doing is duplication this pulse onto another pin A1. However, for some reason I am getting very short drops in the positive pulses, anyone have any idea's why? The IOC interupt is called near the start of the main program and does not include any other pins and triggers on both edges (there are no other interupts in the program).

Thanks

IOC 3.jpg
IOC 3.jpg (37.92 KiB) Viewed 1039 times


IOC 2.jpg
IOC 2.jpg (69.41 KiB) Viewed 1039 times


IOC 1.jpg
IOC 1.jpg (83.87 KiB) Viewed 1039 times

User avatar
Benj
Matrix Staff
Posts: 14461
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4524 times
Been thanked: 4194 times
Contact:

Re: IOC dilema

Postby Benj » Fri Sep 13, 2019 3:01 pm

Hello,

To discount anything in your program causing the problem can you disable the other code or at least add a while 1 loop so that it enables the interrupt and then loops forever in main without doing anything else.

I'm thinking maybe an ADC read on that pin or something else similar is maybe switching the pin to an input temporarily.

stefan.erni
Posts: 539
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 170 times
Been thanked: 158 times
Contact:

Re: IOC dilema

Postby stefan.erni » Fri Sep 13, 2019 4:30 pm

Hi Lord Grezington

Disable the NO Output and take a mesurment. If the Pin A1 still goes down, something switch it down (what Ben says)
If it is stable always 1 then you have a IOC problem.(maybe)

regards

Stefan

Lord Grezington
Flowcode V4 User
Posts: 233
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 18 times
Been thanked: 25 times
Contact:

Re: IOC dilema

Postby Lord Grezington » Mon Sep 16, 2019 11:15 am

Thanks Ben & Stefan

Yes, its looks to be the analogue input! How/Why is the analogue input affecting the IOC though when the analogue input is is the main program? Will the anlalogue input (RC4/AN20) still affect the IOC on RC2 just because its on the same port?

I am guessing I need to change RC2 to a general IO and not an analogue input to resolve this problem? I have had a look into the datasheet and I cant seem to find the right register to make the change. Apparetnly the datasheet file size is too large to upload, so here is a link. https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=2ahUKEwj3nvj-jdXkAhXwRxUIHSCeAy8QFjAAegQIAxAC&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2FDeviceDoc%2F40001800C.pdf&usg=AOvVaw0Hfb7ykRgkUZ5_RWBJCBDw

Thanks

Lord Grezington
Flowcode V4 User
Posts: 233
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 18 times
Been thanked: 25 times
Contact:

Re: IOC dilema

Postby Lord Grezington » Tue Sep 17, 2019 2:44 pm

Sorry to push

I have shown the ADC is the affecting the IOC, so how to I stop it from doing it?

Thanks

User avatar
Benj
Matrix Staff
Posts: 14461
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4524 times
Been thanked: 4194 times
Contact:

Re: IOC dilema

Postby Benj » Fri Sep 20, 2019 10:39 am

Hello,

Not sure how to help any further. I would probably need to see your project to offer any further advise. You can send via a PM if you do not want it to be made public. Ideally you can strip the file back to the basics that show the problem then this would be very helpful in terms of making sure we see the wood for the trees.

Lord Grezington
Flowcode V4 User
Posts: 233
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 18 times
Been thanked: 25 times
Contact:

Re: IOC dilema

Postby Lord Grezington » Fri Sep 20, 2019 3:32 pm

Thanks Ben

I have stripped the program back to bare basics, I now no longer even have the input pulse but still getting a strange output. FC program is attached and the output is below.

IOC ADC Issue.png
IOC ADC Issue.png (55.67 KiB) Viewed 903 times



Thanks
Attachments
IOC ADC Issue.fcfx
(15.82 KiB) Downloaded 18 times

User avatar
Benj
Matrix Staff
Posts: 14461
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4524 times
Been thanked: 4194 times
Contact:

Re: IOC dilema

Postby Benj » Fri Sep 20, 2019 3:59 pm

Hello,

If you add a delay into the loop then does this change anything in terms of wierdness? Just looking at the CAL code for the ADC (pin C4 - ADC20) and it all seems to check out.

To sum up your various connections.

You have interrupt on pin C2.

C1 is an analogue input - InputVoltage
C3 is an analogue input - Current
C4 is an analogue input - POT
C6 is an analogue input - Analogue

PWM and PowerOut are both PWM components that are assigned to different pins but both use the same PWM channel.

Have you looked at the errata document for the chip on the Microchip website to see if it is a known silicon bug?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1172
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 372 times
Been thanked: 593 times
Contact:

Re: IOC dilema

Postby QMESAR » Sun Sep 22, 2019 6:05 pm

Hi.
I haven't studied your device datasheet but recall had a similar situation make sure if the pins you are using is also connected to the comparators
make sure you switch the comparators OFF :D