Page 1 of 2

No funciona proyecto con pic16F883

Posted: Sat Feb 25, 2023 12:30 am
by Fer_taca
Hello,

I have a project done and apparently it works as I want in the Flowcode simulator itself. Once this has been verified, the next thing I have done is obtain the hexadecimal file.
The compiler seems to have worked correctly, because in the end I get the hex file.
Then I save the hex file in the pic and it doesn't work.

When configuring and indicating that everything is fine, the texts of the attached file appear to me.

Can you tell me and/or help me what can happen?
Thanks in advance

F.

Re: No funciona proyecto con pic16F883

Posted: Sat Feb 25, 2023 8:24 am
by mnf
Hi

Looks like you have a function that calls itself either directly or indirectly.

Please post your code (the..fcfx file) and someone will take a look...

Martin

Re: No funciona proyecto con pic16F883

Posted: Sat Feb 25, 2023 1:14 pm
by Fer_taca
It's weird because I don't think there is anything nested.

Sorry for forgetting.
I thought I had attached it too.
Attached the fcfx file

F.

Re: No funciona proyecto con pic16F883

Posted: Sat Feb 25, 2023 2:01 pm
by mnf
I think one problem is that the interrupt handler (Cuentar_Grabar) calls Multiplexado. This will cause 'issues' if an interrupt occurs whist the code is in Multiplexado - although the compiler has attempted to negate this by duplicating the function - I think it will still cause things to 'break'.

Calling Multiplexado at 122Hz - may cause a lockup (how long does Clear/Show digit take) - the interrupt handler needs to be kept short and quick...

There also seems to be a very limited stack size on the MCU you are using - an issue that doesn't affect simulation (an interesting feature -- maybe it should?)

Martin

Re: No funciona proyecto con pic16F883

Posted: Sat Feb 25, 2023 11:23 pm
by Fer_taca
mf,
Even though I delete the interrupt multiplexing block, the same messages continue to appear and therefore the program works just as badly.

Re: No funciona proyecto con pic16F883

Posted: Sun Feb 26, 2023 10:13 am
by mnf
Next problem.

There is a call to multiplexado in entrada_paros.

This won't work in an interrupt routine (imagine the problem if the display is updating when an interrupt occurs)

Can I also suggest using an array for the individual digits...

Martin

Re: No funciona proyecto con pic16F883

Posted: Sun Feb 26, 2023 6:46 pm
by Fer_taca
Thanks Martin for the responses.
I have deactivated multiplexado the pulse input icon and although ag is now seen on the displays, the numbers still do not appear correctly and it is not appreciated that the program works as it should.
When compiling I still get a series of messages:

using updated 32-bit floating-point libraries; improved accuracy might increase code size
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbdiv.c: 4: non-reentrant function "___lbdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lbmod.c: 4: non-reentrant function "___lbmod" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwdiv.c: 6: non-reentrant function "___lwdiv" appears in multiple call graphs and has been duplicated by the compiler
C:\PROGRA~2\FLOWCO~1\COMPIL~1\pic\sources\common\lwmod.c: 6: non-reentrant function "___lwmod" appears in multiple call graphs and has been duplicated by the compiler
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 77: (1090) variable "_FCI_TMP_INT" is not used (warning)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 76: (1090) variable "_FCI_TMP_STR" is not used (warning)

Is there anything else I can do to fix the problem?
Thanks in advance
fermin

Re: No funciona proyecto con pic16F883

Posted: Sun Feb 26, 2023 9:45 pm
by mnf
The warning about non re-entrant function means that a function may occur in an interrupt - but probably shouldn't (the result will be incorrect if an interrupt occurs whilst the code is doing a division and the interrupt handler uses division for example) So you should remove calls to divide and mod (/ and %) operators in interrupt handlers.

You can ignore the variable not used warnings...

What are you trying to achieve? Does the code do anything on hardware (light some or just wrong segments)

Martin

Re: No funciona proyecto con pic16F883

Posted: Sun Feb 26, 2023 10:12 pm
by Fer_taca
Again thank you very much for the answer.
He explained it to me well and I understood correctly.
I have removed the divider block from the pulse input interrupt.
I have compiled it and no indication appears anymore.
Tomorrow I record the pic and try.
I will indicate the result, although now I have observed in the simulator that there are times that I have to press each of the buttons several times for them to react. Ok I'll check it out

What I intend is to make a descending counter once the discount value has been chosen. This will be for pulses on RB0.

Fermin

Re: No funciona proyecto con pic16F883

Posted: Sun Feb 26, 2023 10:22 pm
by kersing
According to the compiler warnings you are using floating point variables. Do you need floating point or would (long) integers be sufficient?

Re: No funciona proyecto con pic16F883

Posted: Mon Feb 27, 2023 10:50 am
by mnf
Take a look at the sample code for the 7seg display (at https://www.flowcode.co.uk/wiki/index.p ... _(Segment))

This uses an interrupt to handle the 'switching' between digits. Note that this can either occur in an interrupt or in the main loop (not both)

I would use something like this with a variable 'count' - that is decremented by a 1s interrupt handler to handle the 'countdown'.

Similarly for 'setting' the number - let the interrupt handler take care of the display (so your code just needs to set 'count'). With buttons you have to watch for 'bounce' (multiple signals caused by the contacts on press) - either use the switch macros to read their state or add a check in code for this (or add a capacitor)

Martin

Re: No funciona proyecto con pic16F883

Posted: Mon Feb 27, 2023 10:36 pm
by Fer_taca
Thanks, Martin.

Before your last answer, I had already reviewed an example from the folwcode wiki and seen how the multiplexing is done.
I have adapted it to my project and when testing I found that our displays blinked very quickly and the values ​​to be represented were barely distinguishable.
I assumed that it was due to the multiplexing frequency and I was going to raise it until I found the most suitable one.
But having seen the example that you have attached, I think the frequency is 250Hz, so tomorrow I will try directly with that frequency.
Once this problem is resolved, I would review the rest of the program and I am sure that I will have some more questions that I hope if not resolved if I will consult again.

Re: No funciona proyecto con pic16F883

Posted: Tue Feb 28, 2023 11:58 am
by mnf
Okay - let us know how it goes...

Martin

Re: No funciona proyecto con pic16F883

Posted: Tue Feb 28, 2023 6:21 pm
by Fer_taca
After the test has been done by increasing the frequency, now the displays can be seen without blinking, but I see a couple of defects that I don't understand why it's happening:
1º the value of the units digit is always reflected in the tens digit.

2º In addition to the above, the segments that should not light up when representing a number also appear lit, although in a more dim way.

Any advice to solve these problems?
I attach the project as it is now. With the multiplexing routine copied from an example on the Flowode wiki.

Once these problems have been solved, I would check the operation of the buttons, although the start-up (B4) and reset (B5) ones do work well.

F.

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 1:27 pm
by Fer_taca
Hello,
I have continued trying to find the defect described in the previous post and I don't see what could be the cause.

I have reduced the program to the maximum so that the status of a button is read and that the value increases with each push and is displayed in one of the 7-segment digits.

Ignoring the problem that may exist with bounces, the example detects when a + pulse is received at B3 by increasing the value of the hundreds digit by one.

In the simulator it works well, but in reality the value to be displayed in the hundreds digit is always reflected in the tens digit. The same happens whatever digits are chosen. Whether they are hundreds, tens or units

But the values are not very well distinguished either because in addition to lighting up the segments that show the value, the rest of the segments that should not light up also light up, although they do so more dimly.

For example, if the value 500 is required to be represented on the displays, it actually appears as 550, but with the "b and e" segments also lit more dimly, so it actually appears as 880. Any idea how to fix this effect?

Attached the example file and the simplified scheme made by hand.

Thanks in advance

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 6:30 pm
by mnf
Just to try and see where the problem lies: Please can you try this - I did a minimal display routine (based on yours - I really just removed the code to modify the values) - but I'd be interested to know if this displays correctly on hardware.
If the clock is correct etc it should countdown at ~1s intervals. If not then we need to dig deeper into the display routine.
Min7Seg.fcfx
(33.02 KiB) Downloaded 319 times
Martin

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 6:52 pm
by Fer_taca
I check and in 10 minutes I answer


F

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 7:17 pm
by Fer_taca
Checked and the answer is disastrous. Nothing more than illegible characters is appreciated.

Can a small video be attached to the forum so I can see the result?

The multiplexing is collected from an example of the Flowcode wiki

F

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 8:03 pm
by mnf
That's interesting - and tells us a fair bit.. How about if you remove the timer interrupt that counts down?

I have a couple of the 7 segment displays - I'll try wiring them up and getting them going. Will have to be a different MCU though..

Martin

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 8:27 pm
by Fer_taca
Martín,
En el ejemplo que has mandado, no hay temporización.
El decremento se realiza por la interrupción y el múltiplexado también se hace por medio de otra interrupcion.
Lo que e yo he mandado es básicamente el ejemplo que hay en la wiki de Flowcode no recuerdo el nombre pero está en la ayuda del funcionamiento de los 7 segmentos. Allí es con incremento y yo necesito decremento.
Decirte que el hardware básicamente está funcionando pues con otros programas realizados en C, Niple, el funcionamiento es ok.
Me hubiera gustado adjuntar el vídeo, no es muy largo pero ocupa mucho. No obstante si me dice dónde puedo enviárselo, se lo mando.
F.

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 8:30 pm
by Fer_taca
O si me manda una dirección de mail, lo pongo en mi Drive para que lo descargué.
Le mando el link de descarga y puede chequear todo mejor.
Creo que en 1 hora lo subo y le mando el link por mensaje privado aquí en el foro.

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 8:34 pm
by mnf
In the example you have sent, there is no timing.
The decrement is done by the interrupt and the multiplexing is also done by another interrupt.
What I have sent is basically the example that is in the Flowcode wiki I don't remember the name but it is in the help of the operation of the 7 segments. There is with increase and I need decrease.
Tell you that the hardware is basically working because with other programs made in C, Niple, the operation is ok.
I would have liked to attach the video, it is not very long but it takes up a lot. However, if you tell me where I can send it to you, I'll send it to you.

Thanks to Google translate 😊

It's true - I did all the timing with an interrupt - one route is to zip the video. Another is Youtube... I can pm you my email...

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 9:30 pm
by Fer_taca
link sent

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 10:08 pm
by mnf
In the clip the digit does appear to be 'counting' down. With lots of extra 'guff' displayed.

I got three digits working with an Arduino - using a 4 digit display (hardware) but treating as 3 individual digits (I ignored the left hand digit)

I used a 1k resistor to each of the digit select pins (although for even brightness it probably should have been a resistor on each segment...)

I 'numbered' the digits 0 -2 (units 0, 10s 1 and 100s 2) - so (in multiplex) if currently displaying units - clear units (which clears the common pin) - and display 10s. If displaying 10s (digit 1) - clear 10s and display 100s. Displaying 100s (2) - clear 100s and display units..
seg7.fcfx
(14.3 KiB) Downloaded 276 times
Sorry - the pins are all for Arduino - my setup is not so neat :-( Just lots of jumpers and 3 resistors...

Martin

Re: No funciona proyecto con pic16F883

Posted: Wed Mar 01, 2023 11:06 pm
by Fer_taca
Downloaded and reviewed the example.

I'll try it tomorrow and report

F.