Page 1 of 1

program works on flowcode but not on hardware

Posted: Thu May 10, 2012 5:15 am
by tompzone
hi, i am having trouble with this code, it's a convolution calculator, a relatively simple operation, (the code is kind of messy and it has to be optimized) on the flowcode simulator it works fine, when i tried it on proteus, it gave me warnings about the memory (on the 16f887a) but when i test it on a real breadboard it keeps sending me the key 1 (i am using the pulldowns so the noise is not a problem) and every time enter one vector (operand for the calculation) it goes crazy keeps sending numbers that are not supposed to be sent and it keeps restarting until i power it down, i changed the chip to a 18f4455 and the simulator now has the same behavior of the real circuit, so i haven't really tested it on breadboard as i suppose it's going to do the same. (i was suspecting that there was a stack overflow, but the compiler didn't warn me and reducing the macros seems to have no effect)

i am posting the code, and i hope you can help me find the problem

Re: program works on flowcode but not on hardware

Posted: Thu May 10, 2012 1:46 pm
by medelec35
Hi tompzone, to my that sounds like an hardware issue.
one of the pins of keypad may be either open circuit, or shorted.

This post may help?:
http://www.matrixmultimedia.com/mmforum ... 93&#p32693

Martin

Re: program works on flowcode but not on hardware

Posted: Thu May 10, 2012 4:09 pm
by tompzone
well i have tested the keypad and the connection is fine, and with a very simple program and it works fine, but the strange thing, this program on the simulator (proteus) with the 16f877a it warns me that it's trying to simulate memory that's not implemented, with the 18f4455 on the simulator it goes crazy just like on the real hardware (i have only tried it with the 16f877a on hardware) so i believe that it's the compiler or something else

Re: program works on flowcode but not on hardware

Posted: Sat May 12, 2012 4:29 am
by tompzone
hi

i got it working it was the connections, i hook the pulldows incorrectly (to the columns) now it's working thanks alot

Re: program works on flowcode but not on hardware

Posted: Sat May 12, 2012 7:58 am
by tompzone
hi, after some small modifications i actually noticed that the program doesnt work, everyhing seems fine but the final results of the calculation are wrong (but the simulator gives the right answer), i tried it with 2 16f877a and one 18f4455, so the chip is not the problem and i dont know what causes the calculations to go wrong, as the rest of the program seems to be working, i am posting the 2 codes the one of the 16f877a and 18f4455 (oscillator 20 mhz)

Re: program works on flowcode but not on hardware

Posted: Sat May 12, 2012 9:35 am
by medelec35
tompzone wrote: i got it working it was the connections, i hook the pulldows incorrectly (to the columns) now it's working thanks alot
No problem, at least your a step closer to get your project working.

I have not check your flowchart yet because I do not know what results to expect on entering a sequence of keys.

Perhaps you can post what keys you press and what the desired results should be (and the wrong results you getting),
as this would take a lot of wild guess work out of the equation.

I have modified your keypad so it matches what the actual key are in the ASCII values within external properties,
so it's less confusing for me, as I was pressing 1, and a 2 was displayed :?
Corrected Keypad1.png
(17.77 KiB) Downloaded 4100 times
Martin

Re: program works on flowcode but not on hardware

Posted: Sat May 12, 2012 8:11 pm
by tompzone
hi
yes about the keypad forgot to change the silks screen on the simulation, well i have taken 2 photos, one of the simulation and the result on matlab (the 2 parameters are shown on the matlab photo they are absolutely the same), the results are the same on both, and a picture of the real project (sorry for the mess but cant take the picture closer as my camera lacks autofocus).

to enter the numbers you simply press the desired number and to accept it press the D key, if you make a mistake you can erase it with the # key, to finish entering the vector (the values) press * (it can hold any kind of single digit number, double digit numbers (ex 10 just press 1 and then 0) and three digit numbers (ex 100 but lower than 150 if its bigger then it rejects it).

both the simulation and real project have the same values and everything seems tor work fine except the final result also i noticed that the results are always different the only digit that seems to be correct is the last one (i am setting every variable to 0 to try to eliminate that but it has no effect)

Re: program works on flowcode but not on hardware

Posted: Sun May 13, 2012 12:10 am
by medelec35
I'm no mathematician, so I will struggle without any explanation how calculations are actually performed especially since your storing variables within string arrays so only ascii can be viewed within the simulator.

What I would recommend is for you to check all your array index numbers as they are going out of bounds.
I will pick on 1 example, but there is more than one array index causing the issue you are having with hardware.

For example:

Code: Select all

 t = corr1[long1] * inverso[cnteta]
You have got inverso[20]
So cnteta can't go any higher than 19
But cnteta is actually going up to 255
Due to the nature of V4 simulation, any index out of bounds will probably be ignored.
However that won't be the case of hardware, you will most certainly get random numbers picked up by t

It is the same for other variables.
e.g other strings going out of bounds are:
corr1 & corr2 as you have got then set at 20 (corr1[20], corr2[20]), yet in Bienvenida macro you have got Loop until contadorcorr = 40
Again with

Code: Select all

t = corr1[long1]*inverso[cnteta]   
I have noticed long1 going to 61, yet index of corr1 should not exceed 19 since as stated above you have got corr1[20]

A suggestion: Just for debugging use the LCD to display information. E.g variables used for indexes, result of intermediate calculations. LCD and RS232 can be a useful tool for debugging.

Hope this take you a step nearer to solving the errors.

Martin

Re: program works on flowcode but not on hardware

Posted: Thu May 17, 2012 3:20 pm
by tompzone
well after checking it step by step i found that indeed that was the mistake with the algorithm and it's fixed, and working, thanks alot!

Re: program works on flowcode but not on hardware

Posted: Fri May 18, 2012 9:45 am
by Steve
Hello tompzone,

As this is a V4 question, I have moved the topic the the appropriate forum.

Re: program works on flowcode but not on hardware

Posted: Fri May 18, 2012 6:20 pm
by medelec35
No problem, just glad you have got it sorted in the end.

Thanks for keeping us informed.

Martin