Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:23 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Wishlist for MMBASIC

     Page 3 of 3    
Author Message
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 12:05pm 19 Jul 2015
Copy link to clipboard 
Print this post

Bob - no worries!
John
 
piclover
Senior Member

Joined: 14/06/2015
Location: France
Posts: 134
Posted: 01:13pm 19 Jul 2015
Copy link to clipboard 
Print this post

I don't understand the intolerance and the hostile replies some are doing in this thread...
I'm just trying to help Geoff taking good decisions and improving his excellent (but not perfect: everything can be perfected, so it's in no way a criticism, just a fact) MMBasic.

I tried to contribute with some constructive suggestions (and I'm surprised some people take them as an attack as either against Geoff, themselves, or whatnot), but I'm not going to enter a sterile argument with people who obviously have their mind set on, I'm afraid, misconceptions.

I'd recommend them to better read the A/D operation chapter of the PIC32MX datasheet: the whole point of the internal voltage reference is to serve as a reference for the ADC itself (i.e. with the voltage reference representing the full scale measurement of the ADC), not to "measure" (more like infer, because you must make and assumption about the actual voltage of the reference) the supply voltage and then scale the measurements made with the said supply voltage as a reference (the supply voltage may not even be constant and the computed voltage you get by reading PIN(0) is therefore not quite valid any more when you perform another measurement a few hundreds of microseconds later).
Again, to people saying that the PIC32MX is broken, please show me the errata... Of course, if you use the voltage reference in a way it was not designed to be used (i.e. attempting to measure it with the ADC instead of just using it as a reference for the ADC), you may indeed find that things don't quite work as you believed it should...

As for contributing code, may I remind people about the very license of MMBasic ?... I can't distribute modified code, and properly implementing a SETADC or similar command does have an impact on how SETPIN & Co work, so it can't properly be done with just a CFunction.


PS: This is my last message about this issue in this thread (again, I'm not here to argue, and Geoff already said he put the issue on his to-do list, which I'm glad for).
Edited by piclover 2015-07-20
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2289
Posted: 01:39pm 19 Jul 2015
Copy link to clipboard 
Print this post

actually, the pin(0) variety of solutions does offer one big advantage: the full range of input voltages (from 0v up to Vcc) is retained. if you use the internal bandgap as the reference for A/D conversions, then analog inputs can only usefully range between 0v and Vref (approximately 1.1v), anything greater than Vref is an overflow (a situation which mmbasic currently need not handle).

yes, you can use an external resistor divider, but it does come through that many folks are not keen to add more than the bare minimum of external components to their micromite designs. and with a divider you then hit the input impedance of the analog pins, which may necessitate adding an opamp buffer, etc, etc.

as it happens, i've just finished writing some arduino (ATmega328p) code that reads the arduino's internal bandgap. completely different processor, i know. the arduinos use Vcc as the 'reference' just as the micromite does, and my code then uses the internal bandgap to provide a correction factor just as pin(0) on the micromite did. in the application, it works extremely well, yielding solid 2-digit results.


cheers,
rob :-)
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 08:25pm 19 Jul 2015
Copy link to clipboard 
Print this post

piclover - don't worry. This forum has previous history of (wrong) assumption(s) that posts were hostile, followed by nasty, personal, posts directed against the person who made the original non-hostile posts. You either put up with being mistreated or leave, I guess.

JohnEdited by JohnS 2015-07-21
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 09:23pm 19 Jul 2015
Copy link to clipboard 
Print this post

Hi piclover,

As John has said, sometimes discussions can get "enthusiastic" 😀😀😀 I am sure that no regular members on the forum comment or respond with the intention of upsetting anyone else, they just somtimes get a little " passionate" about the topic under discussion.

You obviosly have a good amount of technical knowledge and I am sure the forum will welcome comments and contributions if you would care to provide them. Written communication can easily lead to missinterpretation about what the sender realy means so I hope you will put up with us and continue as a forum member.

When you say " Vref is used to provide a reference for the adc system" ,can you expand a little (in a non program language way) on how the referance voltage could be accessed to allow its use in mmbasic eg. I need to measure an external voltage and use Vref to calibrate that reading?

Regards,
Doug.

PS. I am spending a week on a barge in France in September - whereabouts in France do you live?
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 09:35pm 19 Jul 2015
Copy link to clipboard 
Print this post

  Quote  I'd recommend them to better read the A/D operation chapter of the PIC32MX datasheet: the whole point of the internal voltage reference is to serve as a reference for the ADC itself (i.e. with the voltage reference representing the full scale measurement of the ADC), not to "measure" (more like infer, because you must make and assumption about the actual voltage of the reference) the supply voltage and then scale the measurements made with the said supply voltage as a reference (the supply voltage may not even be constant and the computed voltage you get by reading PIN(0) is therefore not quite valid any more when you perform another measurement a few hundreds of microseconds later).


Please can you point me at the correct place in the datasheet and I'll try and code this.

My reading is that the voltage references for the ADC are set using VCFG bits in AD1CON2

and the table on page 17-8 of the PIC32 Family Reference manual does not show the option of using the internal reference
 
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 10:19pm 19 Jul 2015
Copy link to clipboard 
Print this post

  piclover said   I don't understand the intolerance and the hostile replies some are doing in this thread...
I'm just trying to help Geoff taking good decisions and improving his excellent (but not perfect: everything can be perfected, so it's in no way a criticism, just a fact) MMBasic.

I tried to contribute with some constructive suggestions (and I'm surprised some people take them as an attack as either against Geoff, themselves, or whatnot), but I'm not going to enter a sterile argument with people who obviously have their mind set on, I'm afraid, misconceptions.

I'd recommend them to better read the A/D operation chapter of the PIC32MX datasheet: the whole point of the internal voltage reference is to serve as a reference for the ADC itself (i.e. with the voltage reference representing the full scale measurement of the ADC), not to "measure" (more like infer, because you must make and assumption about the actual voltage of the reference) the supply voltage and then scale the measurements made with the said supply voltage as a reference (the supply voltage may not even be constant and the computed voltage you get by reading PIN(0) is therefore not quite valid any more when you perform another measurement a few hundreds of microseconds later).
Again, to people saying that the PIC32MX is broken, please show me the errata... Of course, if you use the voltage reference in a way it was not designed to be used (i.e. attempting to measure it with the ADC instead of just using it as a reference for the ADC), you may indeed find that things don't quite work as you believed it should...

As for contributing code, may I remind people about the very license of MMBasic ?... I can't distribute modified code, and properly implementing a SETADC or similar command does have an impact on how SETPIN & Co work, so it can't properly be done with just a CFunction.


PS: This is my last message about this issue in this thread (again, I'm not here to argue, and Geoff already said he put the issue on his to-do list, which I'm glad for).


+1, fully agree with piclover about Vref implementation.

Very unfortunate, that once again MMbasic discussion is more related to religion than critical technical discussion.

Wonder why you don't see more technically capable people participating, critical constructive questioning, criticism and contribution? Maybe that's the whole idea?

Does this show another weakness of close source design?

Hope the fanboys don't prove my point.







 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 11:18pm 19 Jul 2015
Copy link to clipboard 
Print this post

  Quote  +1, fully agree with piclover about Vref implementation.


These is a confusion about the relationship between Vref and the internal reference.

On the 28-pin chip Vref+ is on pin 2 and vref- is on pin 3

The use of these in ADC conversion is enabled by setting the appropriate VCFG bits in AD1CON2. Allowing these to be used is clearly a good idea but you still need to connect an external source to one or more of them (typically Vref- will be tied to GND and Vref+ set by an external voltage source to create a full scale reading appropriate to the source being measured on the ADC pin in use.

The internal reference voltage is unrelated and is the thing that gives the issue. Geoff stated:
  Quote  Ah, I removed the code for reading the internal reference. Eg, PIN(0). Due to issues in the PIC32MX170 chip this function would occasionally cause the Micromite to restart without warning.


On the MX470 this is a hard issue included in the errata. The cause is that when the internal reference is switched to the ADC it has to charge the capacitance of the ADC circuit. This causes the 1.8V internal supply to the processor to be destabilized causing the processor to crash.
  Quote  18. Module: ADC
Converting the Internal Band Gap (IVREF) voltage
source generates a High-Voltage Detect (HVD)
event and aborts the conversion; therefore, this
feature is not functional.
Work around
None.


Although this isn't included in the errata for the MX170 it sounds as though certain chips are susceptible to the same issue - perhaps it may also be a function of the quality of VCAP.

The interaction between VREF and the internal reference comes with piclover's view that it would be good to use the internal reference as the Vef+ source for the ADC conversion. As per my note above I haven't found how/if this is possible. It isn't mention in the chapter on ADC in the PIC32MX reference manual and the circuit overview diagram doesn't show IVREF as an option to use as VREF+.

I may certainly have missed something - these manuals are huge
If anyone can point me to the relevant manual section I will create a CFunction to test the concept.

UPDATE
I've found how to use an externally supplied VRef+ as IVREF by setting the BGSEL bits in CVRCON, but still can't find how to do the reverse.Edited by matherp 2015-07-21
 
piclover
Senior Member

Joined: 14/06/2015
Location: France
Posts: 134
Posted: 03:35am 20 Jul 2015
Copy link to clipboard 
Print this post

Oops... I should have read the datasheet better myself !
I must therefore break my promise for not making a follow-up, because I must apologize and put things straight...

  matherp said  These is a confusion about the relationship between Vref and the internal reference.[/quote]Yes, I made a confusion, mostly because I come from the PIC18F "world" and that chip does have an internal reference (as well as external ref connectivity, like on the PIC32MX) that can be used by the ADC as Vref+... There's also that link to the comparator setup, in the PIC32MX datasheet from the notes for the ADC setup page, where the IVref (internal voltage reference) can be used... I do apologize for this blunder of mine.

[quote]On the 28-pin chip Vref+ is on pin 2 and vref- is on pin 3.
The use of these in ADC conversion is enabled by setting the appropriate VCFG bits in AD1CON2. Allowing these to be used is clearly a good idea but you still need to connect an external source to one or more of them (typically Vref- will be tied to GND and Vref+ set by an external voltage source to create a full scale reading appropriate to the source being measured on the ADC pin in use.[/quote]
Yes and indeed the availability of an external Vref for the ADC is very desirable, and no, it's not the same thing as measuring with an AVdd-referenced ADC an external "Vref" and then measuring again another voltage from another pin, before finally scaling it to the measured "Vref", because each time you pick up the noise from AVdd (which means you can get twice the peak voltage noise as a cumulative error resulting from the two successive conversions); with the use of an external Vref directly fed to the ADC you only pick up the noise of that Vref source (which can be quite low, and easily 100 times lower than the supply noise with even a simple LM385).
So my original proposal (which was two-folds and also mentioned the external reference capability) still holds. Note that the Vref- capability is also something desirable (typical use: "virtual ground" referenced voltages), even if there are far less practical use cases.

[quote]The internal reference voltage is unrelated and is the thing that gives the issue. Geoff stated:
  Quote  Ah, I removed the code for reading the internal reference. Eg, PIN(0). Due to issues in the PIC32MX170 chip this function would occasionally cause the Micromite to restart without warning.

.../...
Although this isn't included in the errata for the MX170 it sounds as though certain chips are susceptible to the same issue[/quote]Like I said, I'm perhaps just lucky, but in the 3 MX170-based projects I built so far, and which are using PIN(0), I never experienced any issue.

[quote]perhaps it may also be a function of the quality of VCAP.[/quote]In all my Micromite-based projects I use a standard 47µF/6.3V solid tantalum capacitor, as recommended by MicroChip.

[quote]On the MX470 this is a hard issue included in the errata.
I was speaking about the current Micromite MKII, i.e. the MX170... The MX470 being a SMD, and given my declining sight which makes soldering such gazillion-pined SMDs a real nightmare, is of no interest whatsoever as far as I am concerned.
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024