James Newton wrote: > First, I DO use the simulator, and I do understand that it has (a lot > of) advantages. But it always works, and the real device does NOT > always work, and that is why I "don't like" simulators: They are > doomed to succeed. There are only a few limited things that will work in the simulator and not on a real PIC. These are obviously hardware issues, like Vdd not what you think, forgotten or broken bypass cap, MCLR not held as you think, PGM high with LVP enabled, incorrect oscillator selected, or external oscillator hooked up incorrectly. These issues are all pretty easy to verify with a scope and get out of the way. If you can run code on the target PIC at all= , then these issues have most likely been taken care of and the simulator wil= l be useful to debug your code. Put another way, the simulator is for debugging your code, not your hardwar= e setup. Once you get the hardware setup issues out of the way, the simulato= r can be a very useful tool and is definitely a nice debugging environment. > In this specific case: I have a pot connected to AN0 and set so that > 2.5v is on the pin. Now I want to know exactly what ADC count the > chip is reading so I can set that as the midpoint in my code and turn > the motors one direction when the voltage is lower and the other when > it is higher. In theory the threshold is between 511 and 512, assuming you are using a 5V supply. Actually, as long as the pot voltage is derived from Vdd (ratiometric), the absolute supply voltage doesn't matter anyway. One part in 1023 is less than you can set the pot to accurately anyway, so why not just use the 511/512 break to make your decision? If you really need the motor to stop at a specific pot position, you should put a deadband in there anyway. Pots can drift and have some mechanical backlash. I doubt you have 1 part in 1000 long term repeatability anyway, even if you could somehow get back to exactly the same shaft position. If this is user tweaked, 1 part in 1000 repeatability is way more than can be perceived. > With a debugger, I simply read the ADC output register and I'm done. > > How would you get that value without the debugger? Is this all you want to do with the PICKit2? I thought you wanted to debug your code. I was of course mostly referring to using the simulator to debu= g code. You can put a bunch of A/D readings in a file, mutter the right incantations to the stimulus setup, and those values will become successive A/D readings in the simulated code. You can also simply set a breakpoint where you detect A/D conversion done and poke the desired value into ADRESH:ADRESL, then debug the following code to see how it handles that reading. > Go on; tell me how I'm an idiot for not "just" reading the complete > ADC documentation and calculating the correct count reading based on > that. I wasn't going to say "idiot". Besides, the midpoint requires no special calculations. As I said, it's between 511 and 512 if you're using all 10 result bits, between 127 and 128 in 8 bit result mode. > Tell me that you would plug in some code you already have that > transmits the register value on a single pin to a serial port on your > PC. If I really needed to know what a A/D reading was in this setup as a one-off, I would probably use two pins, one clock and one data. A sequence of 10 clocked bits is short enough to be captured on a scope and then analysed by hand. It's only 10 bits after all. > Tell me the simulator has a mode for that, AND that the > simulation will, in fact, match the real output. The simulator can't measure a voltage on a real pin, but that's the .01% problem anyway. The problem is usually what the code does with that reading, or in setting up and managing the A/D in the first place. The simulator can help with those things quite well. The details of ADIF getting set some fixed time after conversion start, ADRES not getting set until then, etc, are all well simulated. > No, no, better yet, > tell me that it's stupid to run motors off a pot reading and that I'm > a moron for even thinking that way. You haven't explained what this PIC is supposed to do, so it's hard to reac= h any conclusions. > Or some other abuse I haven't > even dared to imagine. > > I'm your bitch, bring it "Master". Wow, you ran out of small furry animals to kick or something? I was trying to help. Remember, you came here asking for advice. My life will go on just fine whether you ever get this working or not. I'm willing to help, but if I'd known you were going to be a jerk about it I wouldn't have bothered. I had thought of going back and deleting some of the things I said above, but I already spent the time on them before I realized you decided to be a arrogant ingrate. Maybe they will help someone else trying to debug a smal= l PIC project. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .