Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to simulate analog signal in MPLAB SIM?

Status
Not open for further replies.

jumpjack

New Member
I'd like to simulate an analog sinusoidal input on a pin; can it be done with MPLAB Simulator, or anyother FREE simulator?

It's a 440Hz sinusoid.
 
I'd like to simulate an analog sinusoidal input on a pin; can it be done with MPLAB Simulator, or anyother FREE simulator?

It's a 440Hz sinusoid.

hi,
Extract from MPLAB Help:

A/D Converter (Limited)
All the registers, timing function and interrupt generation are implemented. The simulator, however, does not load any meaningful value into the A/D result register (ADRES) at the end of a conversion.To load meaningful data, use an injection file (see Register Injection). A read of the A/D register will load this data into the register.

Note: If you have trouble with I/O pins on processors that have A/D, make certain that the ADCON registers are configuring those pins for digital I/O rather than for analog input. For most processors, these default to analog inputs and the associated pins cannot be used for I/O until the ADCON (or ADCON1) register is set properly.
Because simulation is to the register level, and not the pin level, bit/pin names will be read as `0', as required for analog, although injected stimulus may have actually changed the value to `1'.
 
I read the help for hours, it's really complex!!!!
I was not able to figure out how to define the signal I need.... Any tip?
I need to put pin high, then low after 26 ms, then high after 26.... Should I add one line per each level change? at 26, 52, 78 ms..... 440 times?!? There is a REPEAT function, but I can't understand how it must be set: repeat every... what? Repeat which rows?!?
 
Is this what you are trying to do? Note it's 2.6mS (will give 192Hz). For 440Hz it should be 2.2mS overall - 1.1mS each half cycle.

Mike.
 

Attachments

  • 44Hz.png
    44Hz.png
    22.1 KB · Views: 1,481
Is this what you are trying to do? Note it's 2.6mS (will give 192Hz). For 440Hz it should be 2.2mS overall - 1.1mS each half cycle.

Mike.

almost. I have to act on the comparator, not on the AD converter.
So the number after the "after:" has the same unit of "time units" on the left...:rolleyes: What a hugly GUI....:mad:

Anyway you're right, I have 2.27 ms, not 26! :rolleyes:

But the help says that timings in first columns are absolute, not relative, they all start counting from 0; so I guess I should use 2600 and 5200. And I can't understand what to put in "restart at:" field...
 
Last edited:
Yes, my mistake, they are absolute. In that case I would put in 1300,3900 and restart at 5200.

Mike.
 
Sorry, mixed my boxes up. It should be repeat after 5200 and restart at zero. Does that make more sense?

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top