Page 1 of 1

ADC sensor Problem

Posted: Tue Apr 06, 2010 5:13 am
by trisb
Hi All

I have been given the task of making a flow monitor and temp monitor system, But I am running into a few problems,

I have used a example file (Thank's Matrix Team) and adapted it to run with my flow sensors. I have got the program to run fine with just one sensor. stage one complete 8)
Now I would like to run 2 flow sensors, here is where I am getting problems, if I add a second sensor the input for sensor one is picked up buy sensor 2 as well and vice versa.

Form what I can tell this problem is caused by the loop on the main where the program is looking at the inputs, if i remove this the problem goes away how ever i dong get a reading for sensor 2, i have tried to create macros for the inputs, and even port masking and have not been able to succeed.

Can anyone one help me out with this one?

Also has anyone had problems with the ICD2/USB jumper's on the EB 006 program board..

Thanks

Tristan

Re: ADC sensor Problem

Posted: Tue Apr 06, 2010 6:00 am
by medelec35
Hello trisb. Your programs not working because in main, the loop is only waiting for 1 input at a time. So its only waiting for A0 to be triggered, when it is, then waiting for A1 to be triggered...and so on. I am assuming your looking for a pulsed o/p from both sensors?
I think Best way is to change your LCD to a different port. Then use port b interrupts. Port B is not maskable so you will need to write a macro to determine which pin triggered the interrupt. Lack of macro is probably the reason why your port b interrupt did not work.
Here is a port b detection macro from one of my projects, it could give you an idea of how to set up interrupt macro. All you need to do is goto macro menu, and import macro.
Hope this helps.

Re jumpers: Yes this is know issue, and as far as I know it is being looked into and probably resolved already. Matrix staff would be able to answer that one better.
There is a post by Steve here:
http://www.matrixmultimedia.com/mmforum ... 35&p=16685

Re: ADC sensor Problem

Posted: Tue Apr 06, 2010 2:20 pm
by trisb
Thanks Medelec35

I will have a play with this and see if i can get it to run.

Tris

Re: ADC sensor Problem

Posted: Tue Apr 06, 2010 6:07 pm
by medelec35
I have modified your version, and used it with RB6 and RB7. (only because RB0 and RB1 port B don't simulate, but work on real hardware). Interrupt changed to trigger macro every second. I have used Freq = freq+100 on active low. (so frequency is increased by 100 every time the port goes from high to low. You should be able to change that easy enough.
There are other issues with your original software. 1) You have set Int0 interrupt for 75Hz which means it triggers every 1/75 = 13ms. This means you call your Flows_Sensors macro every 13ms, not every second.
2) I don't believe it is a good idea to call a macro from within an interrupt, I'm sure it will cause all sorts of problems on real hardware.

3) if you are timing by the second, should per min = per sec X 60 and not / 60. Although you did do freq = freq+100 on each detection so that might eliminate points 1 and 3. Note sure since I have not researched in to flow rates like you would have.

Re: ADC sensor Problem

Posted: Wed Apr 07, 2010 2:14 am
by trisb
thanks medelec35

you have saved me some time here.

Thanks for the pointers i have adjusted Int0. still a new to all this all the little tips help.

all I have to do now is add in my temp monitor section..

thanks

Tristan

Re: ADC sensor Problem

Posted: Thu Apr 08, 2010 5:48 am
by trisb
Hi Guys

I have got my flow sensors running fine. ( Thanks medelec35 for the help) but now need a bit more assistance. :)

I am running into problems, trying to add in a flow and return, sensors.
I have done some testing with LM35 (0 to 100c) and can get one on its own to read ok but if I add a second I run in to similar problem, like I was seeing with the flow sensors. and being new to this..I am not sure of the best way to solve this problem.

I have one on AN0 and one on AN1. this is working on the simulation fine, how ever when I run it on my chip on a test rig. the input on ANo is also reading across to in put an1. and it also affects the flow sensors. With out the temperature part the flow sensors work great. how ever I need to have the temperature part as well.

how do I go about getting each one of these Independent of each other. or do i need to do some thing similar with the temp sensors as medelec35 showed me with flow sensors.

If anyone one could help or has some thing I can reference. it would be appreciated.

thanks Trisb

Re: ADC sensor Problem

Posted: Thu Apr 08, 2010 12:06 pm
by medelec35
I have noticed your not calling Return_Temp macro. Was it previously called and found was not working? Since is not working in the simulation.
Also I would guess you will be getting incorrect flow rate readings.
Reason for this is you are calling for RB_changed macro in main, which is wrong.
You need to remove calling for macro, instead setup portB interrupt to call for macro. You you don't then while program is doing a routine like updating LCD, the flow sensor could detect flow but be ignored.

Re: ADC sensor Problem

Posted: Thu Apr 08, 2010 2:02 pm
by trisb
HI medelec35

The return_Temp macro was on the main section with the Flow_Temp, how ever i dropped it out of this file as i was testing some thing else..

As for the Flow sensors. I tried the way you set them up but i was not getting them to read.. I found i got them to read better this way i also had to change the INT TMR0 timing back up. as well.. after making the changes and moving the flow sensors to B0 and B1. i am getting them to read great on my PCB, but i am now have a but of trouble with the temp sensors.

Trisb

Re: ADC sensor Problem

Posted: Fri Apr 09, 2010 2:47 pm
by trisb
Hi Guys

Thanks for all of your help. (medelec35 your are a star.)

I have found the problem.
It turns out I had a bad Temp module. along with a floating input.
Their are a few thing that need to be sorted. how ever all is good.
If any one is interested in the flow sensors i am using drop me a PM. they are ideal for PC cooling and are easy to setup.

Re: ADC sensor Problem

Posted: Fri Apr 09, 2010 3:02 pm
by medelec35
Your welcome. Glad you got it sorted. I was going to say, post your current flowchart with all macros and portB int in place and I will take a look tonight. But don’t need to now :P

Have you got it working with or without portb interrupts in the end? If without, then best to use portb interrupts so you won’t miss any triggers. If don’t work with interrupts, then the reason for that could be looked into.

Re: ADC sensor Problem

Posted: Fri Apr 09, 2010 3:44 pm
by trisb
Hi Medelec

I have Just tried the software, and have put Portb int in place, and i did not get any reading on the flow sensors, If i remove the Interrupt form the start of the software, and put RB_change in the main loop they work fine.

Re: ADC sensor Problem

Posted: Sun Apr 11, 2010 5:01 pm
by medelec35
Hello trisb.

I have changed how the flow rate is detected.It dos it in a smarter way. It just reads port once and not twoce. I believe reading twice (if 2nd flow meter changed just before 2nd is read,) then errors could be induced. Even if you are not going to use it, woud you mind checking this works on real hardware please and let me know if works ok.

Re: ADC sensor Problem

Posted: Sun Apr 11, 2010 9:13 pm
by trisb
Hi Medelec35

I have tired you modified software, and we are still not getting a reading form the flow sensors.
I have made a watered down version with only the flow sensors, (See attached). when you do a simulation of this you don't, get the LCD part come up have ever when i run this on the board the LCD portion does work.

The only part I change don your part was the inputs to RB0 & RB1.

Thanks
Tris

Re: ADC sensor Problem

Posted: Tue Apr 13, 2010 10:10 am
by medelec35
trisb wrote:after making the changes and moving the flow sensors to B0 and B1.
Trisb
For future reference,I just realised Why you project does not work with portB interrupt on change.

Chips that have non maskable portB IOC like your chip, interrupt only works with RB4 to RB7. So if connected to RB0 - RB3, it wont work. I did make a slight mistake with last attachment, so here is corrected version for any one who is interested.

Re: ADC sensor Problem

Posted: Tue Apr 13, 2010 7:04 pm
by trisb
Hi medelc

I will change the flow sensors over to the other inputs and see if this works.

Thanks Trisb