Search found 257 matches

by jadiflow
Wed Oct 21, 2020 12:26 pm
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

Re: ADC ground ref setting

Martin, thanks for chiming in. As I understand it, if you select external reference (ref+) in the ADC setup it also automagically sets ref- to an external pin, not to Vss. In my case I route both ref+ and ref- from the source to the controller board to be sure I do not pick up any DC offset on the w...
by jadiflow
Wed Oct 21, 2020 9:57 am
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

Re: ADC ground ref setting

Stefan, the PIC16F1788 has no analog power pins.

BTW: When I connect the ref- pin 4 to Vss it works very well with just an LSB or two error. I tried to recreate that by setting ADCON1:2 to zero, make Vss the ref-, but that didn't have the same result. Hmmm.
by jadiflow
Wed Oct 21, 2020 9:05 am
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

Re: ADC ground ref setting

Hello Stefan, I kept the source impedance low, 499 ohms. I will check those things you mentioned. I had another question: if I use the ADC in single ended mode, what is the reference for the S/H input? I know that the reference voltage for the ADC can be external, but what is then the ref for the in...
by jadiflow
Tue Oct 20, 2020 4:32 pm
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

Re: ADC ground ref setting

Hello Stefan, The situation is a bit more clear after I did some more testing today. I am measuring with the DMM directly on the ADC input pins, pin 4 (-ref) and pin 24, the AN9 input I use, measuring less than 1mV. I have a short routine that sets ADCON2 bits 2, 1, 0 to 101, then reads the ADC (8 s...
by jadiflow
Tue Oct 13, 2020 7:53 pm
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

Re: ADC ground ref setting

Hello Stefan, thank you for this! When I do this in the initialization, at the start of the program, is that then not overridden when the ADC is initialized? Not sure when the ADC initialization happens; does it happen with the first macro call to it? If that happens and there is an error in that pr...
by jadiflow
Tue Oct 13, 2020 1:32 pm
Forum: 8-Bit PIC
Topic: ADC ground ref setting
Replies: 11
Views: 433

ADC ground ref setting

Hi all, I have a long standing issue with the ADC in my PIC16F1788. I have set the ADC ref to external pin 5, and supply that with a 4.096 ref and that seems to work OK. I am assuming that the ADC ground ref is set to external as well, pin 4. But it seems that the PIC actually uses its Vss as the AD...
by jadiflow
Tue Oct 13, 2020 1:17 pm
Forum: Programming Tips & Tricks
Topic: Multiply integer with float?
Replies: 3
Views: 413

Re: Multiply integer with float?

Thanks Martin, that is helpful.

Jan Didden
Linear Audio
by jadiflow
Tue Oct 13, 2020 11:53 am
Forum: Programming Tips & Tricks
Topic: Multiply integer with float?
Replies: 3
Views: 413

Multiply integer with float?

Hi all, question: if I multiply an integer with a floating point number, is the result a float? Will it work correctly?

Jan Didden
Linear Audio
by jadiflow
Mon May 13, 2019 11:17 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Re: Workaround for fround(x,y) for PIC?

Hi Medelec, thanks for chiming in. I hadn't seen that post, but as noted above have found an extremely simple solution!

Jan
by jadiflow
Mon May 13, 2019 11:13 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Re: Workaround for fround(x,y) for PIC?

Actually, it is much simpler ...
Just add 0.005 and display only 2 decimals. If the 3rd decimal is > 5, it automagically rolls over to 1.01, if not it remains 1.00 .

Jan
by jadiflow
Mon May 13, 2019 10:21 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Re: Workaround for fround(x,y) for PIC?

This works, as noted, though feels awkward.

Jan
by jadiflow
Mon May 13, 2019 10:01 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Re: Workaround for fround(x,y) for PIC?

Martin, I tried the attached, which should be equivalent to your example, but it does not give what I expected. With an initial value of 1.006 I expect a rounding to 1.01 but I am getting 1.00 . What am I missing?

Jan
by jadiflow
Mon May 13, 2019 9:39 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Re: Workaround for fround(x,y) for PIC?

Thanks Martin, I'll try that. Certainly looks smarter than my method ;-)

Though I am new to the .mul etc format.

Jan
by jadiflow
Sun May 12, 2019 9:22 am
Forum: Bug reports
Topic: Workaround for fround(x,y) for PIC?
Replies: 7
Views: 2771

Workaround for fround(x,y) for PIC?

Hi, As it is known that the math function fround(x,y) doesn't work for the PIC family, I was wondering if anyone has a recommended workaround for it? What I do is convert the float to string, then look at a specific character to see if it is above 5 or not, and if so, add the round to the original n...
by jadiflow
Thu May 09, 2019 3:14 pm
Forum: Programming Tips & Tricks
Topic: Rounding String or Float Variables
Replies: 2
Views: 5414

Re: Rounding String or Float Variables

Can I add my vote that someone fixes this? fround(x,y) doesn't work, instead it work like round(). The floating point number is rounded to the next integer instead of actually rounded up. If it can't be fixed, maybe indicate in the help file that it doesn't work for PIC processors. Jan Didden Linear...
by jadiflow
Thu May 09, 2019 2:05 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from 16F886 ADC? - work-around

Finally compiled the software to another PIC, a 16F1788. Same hardware prototype. This is a 12 bit ADC, so for a 1V input and 4.096 ref I should get a count of 1000, I get 997. Good enough for government work. Actually the ref is 4.102V so that narrows the gap further. Conclusions: - Nothing wrong w...
by jadiflow
Thu May 02, 2019 8:36 am
Forum: Flowcode V7
Topic: Error in EEPROM call
Replies: 4
Views: 1914

Re: Error in EEPROM call

Yes that fixed it, thanks Ben.

Jan
by jadiflow
Wed May 01, 2019 10:41 am
Forum: Flowcode V7
Topic: Error in EEPROM call
Replies: 4
Views: 1914

Re: Error in EEPROM call

Can anybody please tell me if the errors noted in the previous post are in my app or in the library files?

Thanks,

Jan
by jadiflow
Tue Apr 30, 2019 10:02 am
Forum: Flowcode V7
Topic: Error in EEPROM call
Replies: 4
Views: 1914

Re: Error in EEPROM call

I just changed the controller type from 18F25K42 to an 18F25K40 which has the same EEPROM location and same EEPROM size, and that compiles without errors. So it seems that the EEPROM library somehow has an error in the definition for the 18F25K42. Edit: tried 18F26K42, which can be selected but when...
by jadiflow
Mon Apr 29, 2019 7:21 pm
Forum: Flowcode V7
Topic: Error in EEPROM call
Replies: 4
Views: 1914

Error in EEPROM call

Out of frustration that I can't get the 16F886 ADC working correctly I decided to get another PIC and see if that works better. PIC18F25K42 has the same package and the same pin connections so completely functional and physical compatible. It even has a 12 bit ADC versus 10 bit for the 'F886. But no...
by jadiflow
Mon Apr 29, 2019 5:23 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from ADC?

Set ADCON1 register bit 5 should switch the 0V ref to the '-Ref' pin. No change.
by jadiflow
Mon Apr 29, 2019 4:06 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from ADC Q to Leigh

Hi Leigh, Flowcode offers me a selection of ADC ref voltages, either Vdd or 'Vref-pin'. However the chip itself also offers the selection of the 0V ref for the ADC, either Vss or the -Vref pin. I am returning the gnd of the voltage to be converted to this pin, but if the chip configuration has been ...
by jadiflow
Mon Apr 29, 2019 2:24 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from ADC?

Hung a cap on that an9 pin, as well as a scope probe. See some switching noise but not more than +/-4mV peak.
by jadiflow
Mon Apr 29, 2019 1:56 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from ADC?

Not clear what type of error it is: Vin exp.cnts act.cnts error 2.076 504 499 5 1% 1.499 375 363 12 3% 0.974 243 231 12 5% 0.497 124 115 9 7% I did experiment with the sample clock settings and the delay between sampling in the macro, but that doesn't seem to make any difference. Is there a recommen...
by jadiflow
Mon Apr 29, 2019 1:42 pm
Forum: Flowcode V7
Topic: Wrong counts from ADC?
Replies: 10
Views: 2961

Re: Wrong counts from ADC?

OK, went back and inserted 1.006V DC, on a 6.5 digit DMM, directly at the an9 pin on the pic, from a DC power supply. That does make a difference, count is now 243. Still 7 counts (28mV) missing.

Jan