Reply by alex...@freemail.gr January 2, 20112011-01-02
The circuit i want to make is a controller for a bipolar motor with 2 H-bridge drivers, the adc will measure the current and will change the pwm duty cycle and will also control a chopper to limit the current to the coils of the motor.
It will also translate the step and dir input signals to motor rotation.
I have tried with avr but the adc was not fast enough.
I have already ordered a couple of lpc2103 but the circuit is not a simple one and i would like to see the result and verify the correct operation of the code and result on the motors before i apply it to a real circuit.
Thank you for your help, i will probably use lpc2131 inctead for simulation and i will make the small modifications needed in the end to port the project to lpc2103.

Alex

--- In l..., "Bob T" wrote:
>
> Alex,
>
> may be it's just ,e but if the is an inexpensive hardware available it always beats a simulator or Proteus.
>
> To check out your program you might want to get a low cost LPC2103 board, e.g. from Olimex or other sources. Run your software on that hardware and do not waste more time on simulating such simple things.
>
> just my 2 cents, Bob
>
> --- In l..., alexan_er@ wrote:
> >
> > Thank you for your reply, and happy new year to all members.
> >
> > Yes the debugger is actually the simulator of uvision4, you are correct.
> > I'm testing the code in proteus simulation not in a real device, I want to design a complete circuit before i apply it to a real chip.
> > I think there is something wrong with the simulation model, maybe it doesn't turn the pin22 to adc input because i can't blame any of the other settings.
> > When i change the pin configuration of the chip to work as an adc input the pin configuration table of proteus shows AD0 for lpc2131 (and works correctly giving a result) and -- for lpc2103, i don't know if it should also show AD0.
> > I have tried with different pinsel settings, 01 and 10 instead of the correct 11 but the 10 bit result is always 0 and the pin configuration shows --.
> > Has anyone made any project in proteus using the ADC converter with LPC2103?
> >
> > Alex
> >
> > --- In l..., "Bob T" wrote:
> > >
> > > Hi Alex,
> > >
> > >
> > > "I have tried to use the ADC converter in LPC2103 and everything is set up correctly but the adc converter result is always 0"
> > > assuming you statement is correct, there are tow options. The voltage at the pin is actually 0V or the chip is defect.
> > > If it works in the Keil debugger (isn't it the simulator?) that indicates correct code and still one of the above options.
> > > The LPC2103 is a mature device and in general the ADC works, has been used 1000s of times.
> > > Have you used a scope for the signal?
> > > Or at least a DMM?
> > >
> > > Good luck
> > > Bob
> > >
> > > , the keil debugger shows that the code works correctly.
> > >
> > > --- In l..., alexan_er@ wrote:
> > > >
> > > > I have tried to use the ADC converter in LPC2103 and everything is set
> > > > up correctly but the adc converter result is always 0, the keil debugger
> > > > shows that the code works correctly.
> > > > I have also tried with burst mode and different inputs but the result is
> > > > still 0, the result and overrun bits work fine.
> > > > I have also tried the code with lpc2131 and works fine there (with
> > > > different pinsel)
> > > > In proteus i have added the ADDR register to the watch list,the result
> > > > becomes one as it it supposed to but the result bits (ARRD 15:6) are
> > > > always 0 (i feed the input with different voltages but nothing changes)
> > > > The ADCR (added in watch list ) shows that the settings are correctly
> > > > applied (input 0, clkdiv=3, pdn=1, start=1 ).
> > > >
> > > > #include
> > > >
> > > > int main(void)
> > > > {
> > > > // P0.22: AD0.0 (Analog Input 0)
> > > > PINSEL0=0x00000000; // 0b00000000000000000000000000000000
> > > > IODIR=0x000003FF; // 0b00000000000000000000001111111111
> > > > PINSEL1=0x0000f000; // 0b00000000000000000011000000000000
> > > >
> > > > // PCLK= 15Mhz
> > > >
> > > > // input 0 selected
> > > > ADCR |= 0x1;
> > > >
> > > > // division by 3+1 15Mhz/4=3.75Mhz
> > > > ADCR|= 0x300;
> > > >
> > > > // a/d operationl
> > > > ADCR|= 0x200000;
> > > >
> > > > // start convertion now
> > > > ADCR|= 0x1000000;
> > > >
> > > > while ((ADGDR&0x80000000)==0);
> > > > IOPIN=((ADGDR& 0xffc0)>>6);
> > > >
> > > > while(1);
> > > > }
> > > >
> > > > Anyone else having problems with LPC2103 (and 2101 and 2102 ) in adc
> > > > conversion?
> > > > Is there any work around?
> > > > Using proteus 7.7 sp2 and keil uvision4
> > > >
> > > > Thank you
> > > > Alex
> > > >
> > >
>

An Engineer's Guide to the LPC2100 Series

Reply by Bob T January 1, 20112011-01-01
Alex,

may be it's just ,e but if the is an inexpensive hardware available it always beats a simulator or Proteus.

To check out your program you might want to get a low cost LPC2103 board, e.g. from Olimex or other sources. Run your software on that hardware and do not waste more time on simulating such simple things.

just my 2 cents, Bob

--- In l..., alexan_er@... wrote:
>
> Thank you for your reply, and happy new year to all members.
>
> Yes the debugger is actually the simulator of uvision4, you are correct.
> I'm testing the code in proteus simulation not in a real device, I want to design a complete circuit before i apply it to a real chip.
> I think there is something wrong with the simulation model, maybe it doesn't turn the pin22 to adc input because i can't blame any of the other settings.
> When i change the pin configuration of the chip to work as an adc input the pin configuration table of proteus shows AD0 for lpc2131 (and works correctly giving a result) and -- for lpc2103, i don't know if it should also show AD0.
> I have tried with different pinsel settings, 01 and 10 instead of the correct 11 but the 10 bit result is always 0 and the pin configuration shows --.
> Has anyone made any project in proteus using the ADC converter with LPC2103?
>
> Alex
>
> --- In l..., "Bob T" wrote:
> >
> > Hi Alex,
> >
> >
> > "I have tried to use the ADC converter in LPC2103 and everything is set up correctly but the adc converter result is always 0"
> > assuming you statement is correct, there are tow options. The voltage at the pin is actually 0V or the chip is defect.
> > If it works in the Keil debugger (isn't it the simulator?) that indicates correct code and still one of the above options.
> > The LPC2103 is a mature device and in general the ADC works, has been used 1000s of times.
> > Have you used a scope for the signal?
> > Or at least a DMM?
> >
> > Good luck
> > Bob
> >
> > , the keil debugger shows that the code works correctly.
> >
> > --- In l..., alexan_er@ wrote:
> > >
> > > I have tried to use the ADC converter in LPC2103 and everything is set
> > > up correctly but the adc converter result is always 0, the keil debugger
> > > shows that the code works correctly.
> > > I have also tried with burst mode and different inputs but the result is
> > > still 0, the result and overrun bits work fine.
> > > I have also tried the code with lpc2131 and works fine there (with
> > > different pinsel)
> > > In proteus i have added the ADDR register to the watch list,the result
> > > becomes one as it it supposed to but the result bits (ARRD 15:6) are
> > > always 0 (i feed the input with different voltages but nothing changes)
> > > The ADCR (added in watch list ) shows that the settings are correctly
> > > applied (input 0, clkdiv=3, pdn=1, start=1 ).
> > >
> > > #include
> > >
> > > int main(void)
> > > {
> > > // P0.22: AD0.0 (Analog Input 0)
> > > PINSEL0=0x00000000; // 0b00000000000000000000000000000000
> > > IODIR=0x000003FF; // 0b00000000000000000000001111111111
> > > PINSEL1=0x0000f000; // 0b00000000000000000011000000000000
> > >
> > > // PCLK= 15Mhz
> > >
> > > // input 0 selected
> > > ADCR |= 0x1;
> > >
> > > // division by 3+1 15Mhz/4=3.75Mhz
> > > ADCR|= 0x300;
> > >
> > > // a/d operationl
> > > ADCR|= 0x200000;
> > >
> > > // start convertion now
> > > ADCR|= 0x1000000;
> > >
> > > while ((ADGDR&0x80000000)==0);
> > > IOPIN=((ADGDR& 0xffc0)>>6);
> > >
> > > while(1);
> > > }
> > >
> > > Anyone else having problems with LPC2103 (and 2101 and 2102 ) in adc
> > > conversion?
> > > Is there any work around?
> > > Using proteus 7.7 sp2 and keil uvision4
> > >
> > > Thank you
> > > Alex
> > >
>

Reply by alex...@freemail.gr January 1, 20112011-01-01
Thank you for your reply, and happy new year to all members.

Yes the debugger is actually the simulator of uvision4, you are correct.
I'm testing the code in proteus simulation not in a real device, I want to design a complete circuit before i apply it to a real chip.
I think there is something wrong with the simulation model, maybe it doesn't turn the pin22 to adc input because i can't blame any of the other settings.
When i change the pin configuration of the chip to work as an adc input the pin configuration table of proteus shows AD0 for lpc2131 (and works correctly giving a result) and -- for lpc2103, i don't know if it should also show AD0.
I have tried with different pinsel settings, 01 and 10 instead of the correct 11 but the 10 bit result is always 0 and the pin configuration shows --.
Has anyone made any project in proteus using the ADC converter with LPC2103?

Alex

--- In l..., "Bob T" wrote:
>
> Hi Alex,
> "I have tried to use the ADC converter in LPC2103 and everything is set up correctly but the adc converter result is always 0"
> assuming you statement is correct, there are tow options. The voltage at the pin is actually 0V or the chip is defect.
> If it works in the Keil debugger (isn't it the simulator?) that indicates correct code and still one of the above options.
> The LPC2103 is a mature device and in general the ADC works, has been used 1000s of times.
> Have you used a scope for the signal?
> Or at least a DMM?
>
> Good luck
> Bob
>
> , the keil debugger shows that the code works correctly.
>
> --- In l..., alexan_er@ wrote:
> >
> > I have tried to use the ADC converter in LPC2103 and everything is set
> > up correctly but the adc converter result is always 0, the keil debugger
> > shows that the code works correctly.
> > I have also tried with burst mode and different inputs but the result is
> > still 0, the result and overrun bits work fine.
> > I have also tried the code with lpc2131 and works fine there (with
> > different pinsel)
> > In proteus i have added the ADDR register to the watch list,the result
> > becomes one as it it supposed to but the result bits (ARRD 15:6) are
> > always 0 (i feed the input with different voltages but nothing changes)
> > The ADCR (added in watch list ) shows that the settings are correctly
> > applied (input 0, clkdiv=3, pdn=1, start=1 ).
> >
> > #include
> >
> > int main(void)
> > {
> > // P0.22: AD0.0 (Analog Input 0)
> > PINSEL0=0x00000000; // 0b00000000000000000000000000000000
> > IODIR=0x000003FF; // 0b00000000000000000000001111111111
> > PINSEL1=0x0000f000; // 0b00000000000000000011000000000000
> >
> > // PCLK= 15Mhz
> >
> > // input 0 selected
> > ADCR |= 0x1;
> >
> > // division by 3+1 15Mhz/4=3.75Mhz
> > ADCR|= 0x300;
> >
> > // a/d operationl
> > ADCR|= 0x200000;
> >
> > // start convertion now
> > ADCR|= 0x1000000;
> >
> > while ((ADGDR&0x80000000)==0);
> > IOPIN=((ADGDR& 0xffc0)>>6);
> >
> > while(1);
> > }
> >
> > Anyone else having problems with LPC2103 (and 2101 and 2102 ) in adc
> > conversion?
> > Is there any work around?
> > Using proteus 7.7 sp2 and keil uvision4
> >
> > Thank you
> > Alex
>

Reply by Bob T December 31, 20102010-12-31
Hi Alex,
"I have tried to use the ADC converter in LPC2103 and everything is set up correctly but the adc converter result is always 0"
assuming you statement is correct, there are tow options. The voltage at the pin is actually 0V or the chip is defect.
If it works in the Keil debugger (isn't it the simulator?) that indicates correct code and still one of the above options.
The LPC2103 is a mature device and in general the ADC works, has been used 1000s of times.
Have you used a scope for the signal?
Or at least a DMM?

Good luck
Bob

, the keil debugger shows that the code works correctly.

--- In l..., alexan_er@... wrote:
>
> I have tried to use the ADC converter in LPC2103 and everything is set
> up correctly but the adc converter result is always 0, the keil debugger
> shows that the code works correctly.
> I have also tried with burst mode and different inputs but the result is
> still 0, the result and overrun bits work fine.
> I have also tried the code with lpc2131 and works fine there (with
> different pinsel)
> In proteus i have added the ADDR register to the watch list,the result
> becomes one as it it supposed to but the result bits (ARRD 15:6) are
> always 0 (i feed the input with different voltages but nothing changes)
> The ADCR (added in watch list ) shows that the settings are correctly
> applied (input 0, clkdiv=3, pdn=1, start=1 ).
>
> #include int main(void)
> {
> // P0.22: AD0.0 (Analog Input 0)
> PINSEL0=0x00000000; // 0b00000000000000000000000000000000
> IODIR=0x000003FF; // 0b00000000000000000000001111111111
> PINSEL1=0x0000f000; // 0b00000000000000000011000000000000
>
> // PCLK= 15Mhz
>
> // input 0 selected
> ADCR |= 0x1;
>
> // division by 3+1 15Mhz/4=3.75Mhz
> ADCR|= 0x300;
>
> // a/d operationl
> ADCR|= 0x200000;
>
> // start convertion now
> ADCR|= 0x1000000;
>
> while ((ADGDR&0x80000000)==0);
> IOPIN=((ADGDR& 0xffc0)>>6);
>
> while(1);
> }
>
> Anyone else having problems with LPC2103 (and 2101 and 2102 ) in adc
> conversion?
> Is there any work around?
> Using proteus 7.7 sp2 and keil uvision4
>
> Thank you
> Alex
>

Reply by alex...@freemail.gr December 31, 20102010-12-31
I have tried to use the ADC converter in LPC2103 and everything is set
up correctly but the adc converter result is always 0, the keil debugger
shows that the code works correctly.
I have also tried with burst mode and different inputs but the result is
still 0, the result and overrun bits work fine.
I have also tried the code with lpc2131 and works fine there (with
different pinsel)
In proteus i have added the ADDR register to the watch list,the result
becomes one as it it supposed to but the result bits (ARRD 15:6) are
always 0 (i feed the input with different voltages but nothing changes)
The ADCR (added in watch list ) shows that the settings are correctly
applied (input 0, clkdiv=3, pdn=1, start=1 ).

#include

int main(void)
{
// P0.22: AD0.0 (Analog Input 0)
PINSEL0=0x00000000; // 0b00000000000000000000000000000000
IODIR=0x000003FF; // 0b00000000000000000000001111111111
PINSEL1=0x0000f000; // 0b00000000000000000011000000000000

// PCLK= 15Mhz

// input 0 selected
ADCR |= 0x1;

// division by 3+1 15Mhz/4=3.75Mhz
ADCR|= 0x300;

// a/d operationl
ADCR|= 0x200000;

// start convertion now
ADCR|= 0x1000000;

while ((ADGDR&0x80000000)==0);
IOPIN=((ADGDR& 0xffc0)>>6);

while(1);
}

Anyone else having problems with LPC2103 (and 2101 and 2102 ) in adc
conversion?
Is there any work around?
Using proteus 7.7 sp2 and keil uvision4

Thank you
Alex