Calulate a pot. + Big letter (modem killer, sorry)

General discussion on mikroPascal.
Post Reply
Author
Message
lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

Calulate a pot. + Big letter (modem killer, sorry)

#1 Post by lgrfbs » 24 Jun 2005 01:18

Hi, my engl. is not 100% good :?

If I know at my pot is 10K and I want too have 3 points on
the pot. typ: 10% 50% 75% position in the pot.
how do I calulate this so I not need too do trail & error for
I too know this numbers of the variabel temp.

Image

Code: Select all

temp:=ADC_read(ANS0);     // ADC conversion
if temp=??? then //Code for 10% event
if temp=??? then //Code for 50% event
if temp=??? then //Code for 75% event
// ??? = the number for choce one event.
Last edited by lgrfbs on 10 Aug 2005 09:37, edited 1 time in total.
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#2 Post by LGR » 24 Jun 2005 01:53

A pot like that is a voltage divider. I don't want to derive the formula here, but it will be a little nonlinear. Best to calibrate the pot using a voltmeter.
If you know what you're doing, you're not learning anything.

Charlie
Posts: 2744
Joined: 01 Dec 2004 22:29

#3 Post by Charlie » 24 Jun 2005 21:31

Hi lgrfbs,

Ony way you can do what you want is (depending on the resolution) is figure out the percentage of the 4 different values for example for 8 bit resolution the total is 255 so 10% of 255 is 25.5 so have 10% displayed on the LCD when the varable reaches 25.5,same thing with 127.5=50% 191.25=75% and 255=100% I was never able to get the LCD to display the Raw data of the Varable as (VAR=adin,0),but I have done it with PDS.IF you want I could write a piece of code and post it.It will be made with a different compiler so you would have to port it ofer to MP.
Regards Charlie M.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

#4 Post by lgrfbs » 24 Jun 2005 23:39

This is my lab code for a/d for a trian-bridge system, baste on
a/d exempel in microPascal.

The 10K Pot Max=1020 this after many attempt, so if I change
the pot too a 20K is it only to *2 ?
or??

Edit: Can it ware so simpelt as Pot Ohm = 1.02 in program or?

Code: Select all

program Test;

var A,temp2,temp : word;
    TidA,t:Byte;

{main procedure}
begin
//******************************************************************************
// microcontroller : P12f675
//
// Project: adc_leds
// This project is designed to work with PIC 12f675;
// with minor adjustments, it should work with any other PIC MCU.
//
// This code demonstrates blinking of diodes connected on gpio.
// ADC conversion value determinate which diodes go on and off.
//******************************************************************************
//program adc_leds;

//begin
  GPIO := 0;
  CMCON := 7;
  TRISIO := 0;           // designate gpio as output
  SetBit(TRISIO,ANS0);   // pin ANS0 as input
  SetBit(TRISIO,ANS1);   // pin ANS1 as input
  ClearBit(ADCON0,VCFG); // Vdd as Vref
 For TidA:=1 to 5 do
 Begin // Power ON visning
  GPIO := $20;   // Tänder LED       1101 1111=DF Orginal
                 //                  0010 0000=20
  delay_ms(300); // Väntar 100ms

  GPIO := $00;   // Släcker alla LED 1111 1111=FF Orginal
                 //                  0000 0000=00
  delay_ms(300); // Väntar 200ms
 End;

    delay_ms(4000);

    repeat                // beginning of a repeat loop
     begin
      temp:=ADC_read(ANS0);     // ADC conversion
      temp2:=ADC_read(ANS1);     // ADC conversion
      A:=1020;// 10K Pot Max=1020
      // 7.83K  8.21K

      // Visar läget för ANS0 - view status for ANS0
      For TidA:=1 to 25 do
      Begin
      temp:=ADC_read(ANS0);     // ADC conversion
       GPIO := $20; // 1 Led blink GP5
       if temp>A then delay_ms(800);
       if temp<=A then delay_ms(200);
       GPIO := $00;
       if temp>A then delay_ms(800);
       if temp<=A then delay_ms(200);
      End;

      delay_ms(4000);

      // Visar läget för ANS1
      For TidA:=1 to 25 do
      Begin
      temp2:=ADC_read(ANS1);     // ADC conversion
       GPIO := $30; // 2 Led blink GP5 & GP4
       if temp2>A then delay_ms(800);
       if temp2<=A then delay_ms(200);
       GPIO := $00;
       if temp2>A then delay_ms(800);
       if temp2<=A then delay_ms(200);
      End;
     End;
    until 0 = 1;         // endless loop (as this condition is never satisfied)
end.
Last edited by lgrfbs on 25 Jun 2005 00:02, edited 1 time in total.
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

Charlie
Posts: 2744
Joined: 01 Dec 2004 22:29

#5 Post by Charlie » 25 Jun 2005 00:00

Hi lgrfbs,
The 10K Pot Max=1020 this after many attempt, so if I change
the pot too a 20K is it only to *2 ?
or??
The Value of the Pot is not critical.The A/d resolution will be 10 bit so you will always get 0-1023 or so regardless of the value or the pot.Does the code work like you want?
Regards Charlie M.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

#6 Post by lgrfbs » 25 Jun 2005 15:37

So I can calc out of this?
Yes, basicly this is some trix left too fix.

Do you want too see this project when is up and runing? :) :roll:
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

Charlie
Posts: 2744
Joined: 01 Dec 2004 22:29

#7 Post by Charlie » 25 Jun 2005 16:06

lgrfbs Wrote:
Do you want too see this project when is up and runing?

Yes I would!:) Thanks!
Regards Charlie M.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

#8 Post by lgrfbs » 30 Jun 2005 22:33

Working code:

Code: Select all

program Thomas_Bro2;
 //******************************************************************************
 // microcontroller : P12f675
 //
 // Svenska.
 // Projekt: Thomas styrsytem för klaffbro
 // Detta projekt är disangat att fungera med PIC 12F675
 // med några mindre ändringar bör det fungera med andra PIC MCU.
 //
 // Denna kod driver en motor på GP3 och GP2.
 // ADC konverterningens värde anger vinkeln bron har och vänte tiden
 // mellan varje bro rörelse.
 //
 // English.
 // Project: Thomas styrsytem för klaffbro
 // This project is designed to work with PIC 12F675
 // with minor adjustments, it should work with any other PIC MCU.
 //
 // This code drives a motor at GP3 and GP2.
 // ADC conversion value determinate the angel fo -b- and the wainting time
 // betwen the -b- events.
 //******************************************************************************
 //program adc_leds;
var Zov,BroVinkel,Tid : word;
    Loopz,PowerON:Byte;

Begin
 //Setup
 GPIO := 0;
 CMCON := 7;
 TRISIO := 0;           // designate gpio as output
 SetBit(TRISIO,ANS0);   // pin ANS0 as input
 SetBit(TRISIO,ANS1);   // pin ANS1 as input
 ClearBit(ADCON0,VCFG); // Vdd as Vref

// Power ON visning
 For PowerON:=1 to 5 do
 Begin
  GPIO := $20;   // Tänder LED       1101 1111=DF Orginal
                 //                  0010 0000=20
  delay_ms(300);
  GPIO := $00;   // Släcker alla LED 1111 1111=FF Orginal
                 //                  0000 0000=00
  delay_ms(300);
 End;

 // Kontrollerar att bron är nere
 GPIO := $00;
 delay_ms(2000);
 PowerON:=0;
 repeat
 Begin
  BroVinkel:=ADC_read(ANS1);  // ADC conversion
  If PowerON=1 then
  Begin            //Block av - Relä (av)läge ner - Motor på
   GPIO := $10;    //Bron var inte nere säncker bron!
   delay_ms(100);  //Pulserar motorstömen för långsam gång
   GPIO := $00;    //Block av - Relä (av)läge ner - Motor av
   delay_ms(100);
  End;
  PowerON:=1;
 End;
 until BroVinkel<=100;
 GPIO := $00;
 delay_ms(2000);

// Huvud progrsm
 repeat                       // beginning of a repeat endless loop
 Begin



  // Väntar inställd tid
  //GPIO := $00;
  Tid:=ADC_read(ANS0);        // ADC conversion
  Zov:=0;
  If Tid<100 then
  Begin
   Tid:=6;                    //6=Test 100=Normal
   //GPIO:=$34;                 // Tag Bort
   delay_ms(2000);
  End;
  //GPIO := $00;                // Tag Bort
  delay_ms(500);
  Repeat
  Begin
   Zov:=Zov+1;
   for Loopz:=1 to 5 do
   Begin
    //GPIO:=$20;                // Tag Bort
    delay_ms(200);
    IF TestBit(GPIO,3)=0 Then
    Begin
     Zov:=0;
     //GPIO:=$04;               //Tag Bort
     Tid:=ADC_read(ANS0);     // ADC conversion
     delay_ms(5000);
    End;
   End;
   //GPIO:=$00;                 //Tag Bort
   delay_ms(200);
  End;
  until Tid=Zov;



  // Höjer bron
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av
  Delay_ms(500);
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$24;     //Block på - Relä (på)läge upp - Motor av
   Delay_ms(500);
   GPIO:=$34;
   Delay_ms(500); //Block på - Relä (på)läge upp - Motor på
  End;
  until BroVinkel>=800;
  GPIO:=$24;     //Block på - Relä (på)läge upp - Motor av
  Delay_ms(500);
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av
  Delay_ms(500);



  //Väntar i 20Sekunder
  For Loopz:=1 to 4 do
  Begin
   Delay_ms(5000);
  End;



   //Sänker bron
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$04;    //Block på - Relä (av)läge ner - Motor av
   Delay_ms(500);
   GPIO:=$14;    //Block på - Relä (av)läge ner - Motor på
   Delay_ms(500);
  End;
  until BroVinkel<100;
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av
  delay_ms(2000);
  GPIO:=$00;     //Block av - Relä (av)läge ner - Motor av
  delay_ms(2000);
 End;
 until 0 = 1;     // endless loop (as this condition is never satisfied)
end.
This code have not run then end-test in modellrail system so all
delay_ms and some levels most fix then mounted in system.

I will setup a complyt homepage about this after the real system test.

Sorry for the english is not 100%.... :roll:
Wordlist Swe-Eng:
PÃ¥=On
Av=Off
Ner=Down
Upp=Up
Tag Bort=Remove this
Höjer=Lift up
Kontrollerar=Controlling
inställd=Set
tid=time
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

Big letter (modem killer, sorry)

#9 Post by lgrfbs » 10 Aug 2005 09:33

Hi
here coms some pic. and movies.
Aftre wishes from Charlie(2005-06-25, 16:06 pm).

Sorry server die online on friday, sorry

The train sensor for reset the time counter too open the bridge.
The 5mm is a IR LED on 18mW and the 3mm is a IR transistor. (Big file)
Image

The electricmotor from a taperecoder runs on 5V.(Big file)
Image

The controller card. (Big file)
Image

The bridge in movement!
Power on & the controller displays with 5 blink that the is ready that drive main program.


The bridge anglesensor

and the final version of the code:

Code: Select all

program Thomas_Bro2;
 //******************************************************************************
 // microcontroller : P12f675
 //
 // Svenska.
 // Projekt: Thomas styrsystem för klaffbro
 // Detta projekt är disangat att fungera med PIC 12F675
 // med några mindre ändringar bör det fungera med andra PIC MCU.
 //
 // Denna kod driver en motor på GP3 och GP2.
 // ADC konverterningens värde anger vinkeln bron har och vänte tiden
 // mellan varje bro rörelse.
 //
 // English.
 // Project: Thomas controls system for drawbridge
 // This project is designed to work with PIC 12F675
 // with minor adjustments, it should work with any other PIC MCU.
 //
 // This code drives a motor at GP3 and GP2.
 // ADC conversion value determinate the angel for bridge and the wainting time
 // betwen the bridge events.
 //******************************************************************************
 //program adc_leds;
var Zov,BroVinkel,Tid : word;
    Loopz,PowerON:Byte;

Begin
 //Setup
 GPIO := 0;
 CMCON := 7;
 TRISIO := 0;           // designate gpio as output
 SetBit(TRISIO,ANS0);   // pin ANS0 as input
 SetBit(TRISIO,ANS1);   // pin ANS1 as input
 ClearBit(ADCON0,VCFG); // Vdd as Vref

// Power ON visning 5 blink
// Power ON show 5 blink
 GPIO := $04;   // Tänder LED       1101 1111=DF Orginal
 delay_ms(1000);
 For PowerON:=1 to 5 do
 Begin
  GPIO := $04;   // Tänder LED       1101 1111=DF Orginal
                 //                  0010 0000=20
  delay_ms(400);
  GPIO := $00;   // Släcker alla LED 1111 1111=FF Orginal
                 //                  0000 0000=00
  delay_ms(400);
 End;

 // Kontrollerar att bron är nere
 // Controlls if bridge is down
 GPIO := $00;
 delay_ms(2000);
 PowerON:=0;
 repeat
 Begin
  BroVinkel:=ADC_read(ANS1);  // ADC conversion
  If PowerON=1 then
  Begin          //Block av - Relä (av)läge ner - Motor på * Block off - Relay (Off) pos. down - Motor on
   GPIO := $10;  //Bron var inte nere säncker bron! ******** bridge is not down!
   delay_ms(50);//Pulserar motorstömen för långsam gång *** Pulse motorpower for slow run
   GPIO := $00;  //Block av - Relä (av)läge ner - Motor av * Block off - Relay (Off) pos. down - Motor off
   delay_ms(50);
  End;
  PowerON:=1;
 End;
 until BroVinkel<=63; // <--- Ner värdet 1 ------------------------------------
 GPIO := $00;
 delay_ms(2000);

// Huvud progrsm
// Main program
 repeat         // beginning of a repeat endless loop
 Begin
 
 
 
  // Väntar inställd tid
  // Want for set time
  //GPIO := $00;
  Tid:=ADC_read(ANS0);        // ADC conversion
  Zov:=0;
  If Tid<100 then
  Begin
   Tid:=100;         // 6=Test 100=Normal
   //GPIO:=$34;      // Tag Bort * Remove
   //delay_ms(2000); // Tag Bort * Remove
  End;
  If Tid>1010 then
  Begin
   Tid:=2;           // 6=Test 100=Normal
  End;
  //GPIO := $00;     // Tag Bort * Remove
  //delay_ms(500);   // Tag Bort * Remove
  
  
  Repeat
  Begin
   Zov:=Zov+1; // Antal varv att vänta * Number of lap too want
   for Loopz:=1 to 30 do
   Begin
    //GPIO:=$20;                // Tag Bort
    delay_ms(106); // Tid att vänta * Loopz värdet
    IF TestBit(GPIO,3)=0 Then
    Begin
     Zov:=0;              // Nollar tidsräknaren * Reset timecount
     //GPIO:=$04;         // Tag Bort * Remove
     Tid:=ADC_read(ANS0); // ADC conversion
     If Tid<100 then
     Begin
      Tid:=100;           // 6=Test 100=Normal
     End;
     If Tid>1010 then
     Begin
      Tid:=2;             // 6=Test 100=Normal
     End;
     delay_ms(5000);      // Väntar ca: 5 Sekunder * Wants 5 Sec.
    End;
   End;
   //GPIO:=$00;           // Tag Bort
   //delay_ms(200);
  End;
  until Tid=Zov; // Klart att höja bron
                 // Clear too take up the bridge

   

  // Höjer bron * Up bridge
  GPIO:=$04;     // Block på - Relä (av)läge ner - Motor av
  Delay_ms(500); // Block on - Relay (Off) pos. down - Motor off
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$24;     // Block på - Relä (på)läge upp - Motor av
   Delay_ms(30); // Block on - Relay (on) pos. up - Motor off
   GPIO:=$34;
   Delay_ms(50); // Block på - Relä (på)läge upp - Motor på
  End;            // Block on - Relay (on) pos. up - Motor on
  until BroVinkel>=365; // <---- Upp värdet ---------------------------------------------
  GPIO:=$24;     // Block på - Relä (på)läge upp - Motor av
  Delay_ms(500); // Block on - Relay (on) pos. up - Motor off
  GPIO:=$04;       // Block på - Relä (av)läge ner - Motor av
  Delay_ms(500);   // Block on - Relay (Off) pos. down - Motor off

   
   
  //Väntar i 20Sekunder * Wants 20 Sec
  For Loopz:=1 to 4 do
  Begin
   Delay_ms(5000);
  End;
  // 5000mS = 5 Sekunder.
  // 5 * 4 = 20 Sekunder.
   
   
   
   //Sänker bron
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av * Block on - Relay (Off) pos. down - Motor off
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$04;    // Block på - Relä (av)läge ner - Motor av
   Delay_ms(50);// Block on - Relay (Off) pos. down - Motor off
   GPIO:=$14;       // Block på - Relä (av)läge ner - Motor på
   Delay_ms(50);   // Block on - Relay (Off) pos. down - Motor on
  End;
  until BroVinkel<63; // <---- Ner värdet -----------------------------------------
  GPIO:=$04;     // Block på - Relä (av)läge ner - Motor av
  delay_ms(3000);// Block on - Relay (Off) pos. down - Motor off
  GPIO:=$00;        // Block av - Relä (av)läge ner - Motor av
  delay_ms(3000);   // Block off - Relay (Off) pos. down - Motor off
 End;
 until 0 = 1;     // endless loop (as this condition is never satisfied)
end.
Files can erase after 20051004, download if you want too save the file!
_____________________________

Edit: fixed the pict. so the are more ok size :D
Last edited by lgrfbs on 29 Sep 2005 21:28, edited 4 times in total.
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

Charlie
Posts: 2744
Joined: 01 Dec 2004 22:29

#10 Post by Charlie » 10 Aug 2005 10:40

Hi lgrfbs,


Thats Very Impressive.:) How long did it take to make all of that?
Regards Charlie M.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

#11 Post by lgrfbs » 10 Aug 2005 13:26

Thank you! :D :D

The bridge was in a scrapbox that Thomas bought for some years then and
then took too 2004-08-?? year before we started the project, as about
1 year but then took we a little every now and then.

All electrically have I received help & advice of two buddies as that I not
needed burn up components because of wrong rates on the components.

And this was me #1 project after LED binking. :D
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

lgrfbs
Posts: 78
Joined: 25 Sep 2004 12:19
Location: Sweden - ADSL 0.5Mbps
Contact:

Re: Big letter (modem killer, sorry)

#12 Post by lgrfbs » 12 Aug 2005 22:00

lgrfbs wrote:Hi
here coms some pic. and movies.
Aftre wishes from Charlie(2005-06-25, 16:06 pm).

The train sensor for reset the time counter too open the bridge.
The 5mm is a IR LED on 18mW and the 3mm is a IR transistor. (Big file)
Image

The electricmotor from a taperecoder runs on 5V.(Big file)
Image

The controller card. (Big file)
Image

The bridge in movement!
Power on & the controller displays with 5 blink that the is ready that drive main program.


The bridge anglesensor

and the final version of the code:

Code: Select all

program Thomas_Bro2;
 //******************************************************************************
 // microcontroller : P12f675
 //
 // Svenska.
 // Projekt: Thomas styrsystem för klaffbro
 // Detta projekt är disangat att fungera med PIC 12F675
 // med några mindre ändringar bör det fungera med andra PIC MCU.
 //
 // Denna kod driver en motor på GP3 och GP2.
 // ADC konverterningens värde anger vinkeln bron har och vänte tiden
 // mellan varje bro rörelse.
 //
 // English.
 // Project: Thomas controls system for drawbridge
 // This project is designed to work with PIC 12F675
 // with minor adjustments, it should work with any other PIC MCU.
 //
 // This code drives a motor at GP3 and GP2.
 // ADC conversion value determinate the angel for bridge and the wainting time
 // betwen the bridge events.
 //******************************************************************************
 //program adc_leds;
var Zov,BroVinkel,Tid : word;
    Loopz,PowerON:Byte;

Begin
 //Setup
 GPIO := 0;
 CMCON := 7;
 TRISIO := 0;           // designate gpio as output
 SetBit(TRISIO,ANS0);   // pin ANS0 as input
 SetBit(TRISIO,ANS1);   // pin ANS1 as input
 ClearBit(ADCON0,VCFG); // Vdd as Vref

// Power ON visning 5 blink
// Power ON show 5 blink
 GPIO := $04;   // Tänder LED       1101 1111=DF Orginal
 delay_ms(1000);
 For PowerON:=1 to 5 do
 Begin
  GPIO := $04;   // Tänder LED       1101 1111=DF Orginal
                 //                  0010 0000=20
  delay_ms(400);
  GPIO := $00;   // Släcker alla LED 1111 1111=FF Orginal
                 //                  0000 0000=00
  delay_ms(400);
 End;

 // Kontrollerar att bron är nere
 // Controlls if bridge is down
 GPIO := $00;
 delay_ms(2000);
 PowerON:=0;
 repeat
 Begin
  BroVinkel:=ADC_read(ANS1);  // ADC conversion
  If PowerON=1 then
  Begin          //Block av - Relä (av)läge ner - Motor på * Block off - Relay (Off) pos. down - Motor on
   GPIO := $10;  //Bron var inte nere säncker bron! ******** bridge is not down!
   delay_ms(50);//Pulserar motorstömen för långsam gång *** Pulse motorpower for slow run
   GPIO := $00;  //Block av - Relä (av)läge ner - Motor av * Block off - Relay (Off) pos. down - Motor off
   delay_ms(50);
  End;
  PowerON:=1;
 End;
 until BroVinkel<=63; // <--- Ner värdet 1 ------------------------------------
 GPIO := $00;
 delay_ms(2000);

// Huvud progrsm
// Main program
 repeat         // beginning of a repeat endless loop
 Begin
 
 
 
  // Väntar inställd tid
  // Want for set time
  //GPIO := $00;
  Tid:=ADC_read(ANS0);        // ADC conversion
  Zov:=0;
  If Tid<100 then
  Begin
   Tid:=100;         // 6=Test 100=Normal
   //GPIO:=$34;      // Tag Bort * Remove
   //delay_ms(2000); // Tag Bort * Remove
  End;
  If Tid>1010 then
  Begin
   Tid:=2;           // 6=Test 100=Normal
  End;
  //GPIO := $00;     // Tag Bort * Remove
  //delay_ms(500);   // Tag Bort * Remove
  
  
  Repeat
  Begin
   Zov:=Zov+1; // Antal varv att vänta * Number of lap too want
   for Loopz:=1 to 30 do
   Begin
    //GPIO:=$20;                // Tag Bort
    delay_ms(106); // Tid att vänta * Loopz värdet
    IF TestBit(GPIO,3)=0 Then
    Begin
     Zov:=0;              // Nollar tidsräknaren * Reset timecount
     //GPIO:=$04;         // Tag Bort * Remove
     Tid:=ADC_read(ANS0); // ADC conversion
     If Tid<100 then
     Begin
      Tid:=100;           // 6=Test 100=Normal
     End;
     If Tid>1010 then
     Begin
      Tid:=2;             // 6=Test 100=Normal
     End;
     delay_ms(5000);      // Väntar ca: 5 Sekunder * Wants 5 Sec.
    End;
   End;
   //GPIO:=$00;           // Tag Bort
   //delay_ms(200);
  End;
  until Tid=Zov; // Klart att höja bron
                 // Clear too take up the bridge

   

  // Höjer bron * Up bridge
  GPIO:=$04;     // Block på - Relä (av)läge ner - Motor av
  Delay_ms(500); // Block on - Relay (Off) pos. down - Motor off
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$24;     // Block på - Relä (på)läge upp - Motor av
   Delay_ms(30); // Block on - Relay (on) pos. up - Motor off
   GPIO:=$34;
   Delay_ms(50); // Block på - Relä (på)läge upp - Motor på
  End;            // Block on - Relay (on) pos. up - Motor on
  until BroVinkel>=365; // <---- Upp värdet ---------------------------------------------
  GPIO:=$24;     // Block på - Relä (på)läge upp - Motor av
  Delay_ms(500); // Block on - Relay (on) pos. up - Motor off
  GPIO:=$04;       // Block på - Relä (av)läge ner - Motor av
  Delay_ms(500);   // Block on - Relay (Off) pos. down - Motor off

   
   
  //Väntar i 20Sekunder * Wants 20 Sec
  For Loopz:=1 to 4 do
  Begin
   Delay_ms(5000);
  End;
  // 5000mS = 5 Sekunder.
  // 5 * 4 = 20 Sekunder.
   
   
   
   //Sänker bron
  GPIO:=$04;     //Block på - Relä (av)läge ner - Motor av * Block on - Relay (Off) pos. down - Motor off
  repeat
  Begin
   BroVinkel:=ADC_read(ANS1); // ADC conversion
   GPIO:=$04;    // Block på - Relä (av)läge ner - Motor av
   Delay_ms(50);// Block on - Relay (Off) pos. down - Motor off
   GPIO:=$14;       // Block på - Relä (av)läge ner - Motor på
   Delay_ms(50);   // Block on - Relay (Off) pos. down - Motor on
  End;
  until BroVinkel<63; // <---- Ner värdet -----------------------------------------
  GPIO:=$04;     // Block på - Relä (av)läge ner - Motor av
  delay_ms(3000);// Block on - Relay (Off) pos. down - Motor off
  GPIO:=$00;        // Block av - Relä (av)läge ner - Motor av
  delay_ms(3000);   // Block off - Relay (Off) pos. down - Motor off
 End;
 until 0 = 1;     // endless loop (as this condition is never satisfied)
end.
Files can erase after 20051004, download if you want too save the file!
_____________________________

Edit: fixed the pict. so the are more ok size :D
ICQ Mess. = Forums name as ref.
If you see stave/grammatical errors is you welcome too tell me.

Post Reply

Return to “mikroPascal General”