dimanche 17 août 2014

calculer la résistance:

Panoramic calcul la résistance "X" d'un diviseur de tension  aux bornes d'une entrée analogique d'une carte "Arduino".
Comme échantillonnage et de 1024 bits la précision n'est pas au rendez-vous.
On peut changer la résistance de "1 k" pour moduler les plages de calcul.
 On utilise toujours la " IO_Acces_COM.dll " pour la "com série".


Code
error_french
width 0,1000:color 0,160,160,200:wait 20
caption 0,"Panoramic et Arduino Uno"
top 0,(screen_y-height(0))/2 :left 0,(screen_x-width(0))/2
dim i,division%,div,nobj,com_ok,a%,a1%,aa%,dat%,donner$, poubele$,tension
dim vr1,ir,rt,rx%
label sp_fin,sp_com_on,sp_reception,sp_Mesure,sp_stop_com
label calcul_resistance
alpha 1
nobj=10: affichtxt(nobj,0,10,width(0)-250,16," PANORAMIC ")
nobj=20 :affichtxt(nobj,0,120,455,20," OHMS "):color 20,220,220,200
 font_name  20,constantia
nobj=30: voyant_automate(nobj,0,120,200,"COM",0)
nobj=40: button_container(nobj,0,220,590,"F I N")
nobj=50: button_container(nobj,0,220,150,"Com On")
nobj=60: button_container(nobj,0,220,250,"Com Off")
nobj=70: affichtxt(nobj,0,250,width(0)-250,86," W"):font_name  71,"Symbol"
nobj=80: button_container(nobj,0,220,455,"Mesure")
nobj=90: affichtxt(nobj,0,10,50,16," Mesure de résistance ")
nobj=120 :affichtxt(nobj,0,120,left(20)+width(20),20,"  W  ")
color 120,220,220,200:font_name  121,"Symbol"
on_click 41,sp_fin
on_click 51,sp_com_on
on_click 61,sp_stop_com
on_click 81,sp_Mesure
' ====================
    end : ' ==========
' ====================
rem #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
 ' ====Fin============
sp_fin:

 terminate
return
' ====================
sp_com_on:
if com_ok=0
com_serie()
end_if
return

' ====================
sub com_serie()
 dim_local rc,rrc
 rem #########################################################
 rem ##### DLL chargée en mémoire  suivant configuration 
 rem #########################################################
 dll_on "c:\dll_Panoramic\IO_Acces_COM.dll"
 rc= dll_call1("ComUsePort",8)
 if rc=1
    rrc= dll_call4("ComConfig",115200,8,1,0)
 end_if
 if rc=1 and rrc=1
    com_ok =1
    position 32,1 :inactive 51: hide 40
 else
    rc= dll_call1("ComUsePort",0)
    dll_off : message "Defaut_com_Serie"
 end_if
end_sub

' =======S/P==Fin=============
sub affichtxt(nxt,par,tpt,ltt,fsize,txt$)
 container nxt:parent nxt,par:top nxt,tpt:left nxt,ltt
 Alpha nxt+1:parent nxt+1,nxt:top nxt+1,10:left nxt+1,10
 font_bold 1:font_size 1,fsize
 width nxt+1,text_width(txt$,1)
 width nxt,width(nxt+1)+20
 font_bold nxt+1:font_size nxt+1,fsize
 caption nxt+1,txt$
 height nxt,height(nxt+1)+20
end_sub

' ====================
sub button_container(nbc,par,tpc,ltc,txt$)
 container nbc:parent nbc,par:top nbc,tpc:left nbc, ltc
 caption nbc ,txt$
 button nbc+1:parent nbc+1,nbc:top nbc+1,30:left nbc+1,10
 width nbc+1,40:hint nbc+1,nbc+1
 width nbc,width(nbc+1)+20
 height nbc,height(nbc+1)+50
end_sub
' ====================
sub voyant_automate(ntp,par,ttp,ltp,txt$,etat)
 container ntp:parent ntp,par:top ntp,ttp:left ntp,ltp
 width ntp,80-20: height ntp,133-50
 font_size ntp,14:caption ntp,txt$
 alpha ntp+1:parent ntp+1,ntp:top ntp+1,48-20:left ntp+1,7
 width ntp+1,64-20: height ntp+1,44:color ntp+1,0,0,0
 progress_bar  ntp+2:parent ntp+2,ntp:top ntp+2,52-20:left ntp+2,11
 width ntp+2,56-20: height ntp+2,36:min ntp+2,0:max ntp+2,1
 hint ntp+2,ntp+2
 if etat=0
    position ntp+2,0
 else
    position ntp+2,1
 end_if

end_sub
' =====réception========
sp_reception:
 if com_ok=1
    a%=DLL_CALL1("ComGetDataIn",adr(dat%))
    pause 5
     ' *****************************************
     WHILE a%>0
         if dat%> 47 and a% <58
            donner$=donner$+chr$(dat%)
         end_if
         if chr$(dat%)="%"
             poubele$=chr$(dat%)
             donner$=trim$(donner$)
             if numeric(donner$)=1 then tension=val(donner$)
             gosub calcul_resistance
             donner$="" :dat%=0 :tension=0
             exit_while
         end_if
        a%=DLL_CALL1("ComGetDataIn",adr(dat%))
        pause 5
     END_WHILE
     ' *****************************************
end_if
return
' ====================
sp_Mesure:
if com_ok =1
  a1%= dll_call1("ComSetDataOut",116)
  ' 116=t pour émettre 1 fois
  pause 4
  gosub sp_reception
end_if
return
' ====================
sp_stop_com:
if com_ok=1
 pause 10
  aa%= dll_call1("ComUsePort",0)
  dll_off
 com_ok=0:a%=0:aa%=0:active 51:show 40
 position 32,0:caption 21,"0.00"
 end_if
return
' ====================
calcul_resistance:
 vr1=tension*(5/1023)
 ir=vr1/1009
 if ir<>0
 rt=5/ir
 rx%=rt-1009:' <= valeur à mesurer de R1
caption 21,str$(rx%)
else
message "Défaut mesure"
caption 21,""
end_if
return
' ====================
' ====================
' ====================
' liste des objets systeme
'
'   FORM          0                       W 1000  H 480
'   ALPHA         1  parent   0  type  6  W    8  H  32
'   CONTAINER    10  parent   0  type 23  W  154  H  44
'   ALPHA        11  parent  10  type  6  W  135  H  24
'   CONTAINER    20  parent   0  type 23  W  118  H  52
'   ALPHA        21  parent  20  type  6  W   99  H  32
'   CONTAINER    30  parent   0  type 23  W   60  H  83
'   ALPHA        31  parent  30  type  6  W   44  H  44
'   PROGRESS_BAR 32  parent  30  type 20
'   CONTAINER    40  parent   0  type 23  W   60  H  75
'   BUTTON       41  parent  40  type  2  W   40  H  25
'   CONTAINER    50  parent   0  type 23  W   60  H  75
'   BUTTON       51  parent  50  type  2  W   40  H  25
'   CONTAINER    60  parent   0  type 23  W   60  H  75
'   BUTTON       61  parent  60  type  2  W   40  H  25
'   CONTAINER    70  parent   0  type 23  W  162  H 165
'   ALPHA        71  parent  70  type  6  W  119  H  40
'   CONTAINER    80  parent   0  type 23  W   60  H  75
'   BUTTON       81  parent  80  type  2  W   40  H  25
'   CONTAINER    90  parent   0  type 23  W  233  H  44
'   ALPHA        91  parent  90  type  6  W  214  H  24
'   CONTAINER   120  parent   0  type 23  W   75  H  52
'   ALPHA       121  parent 120  type  6  W   53  H  34

' ====================


code



// resistance_20140514
//........................
int mesure=0;
//.............................
void setup() {
Serial.begin(115200); 
}
//============================
void loop(){
   if (Serial.available()!=0){
  module_reception();}
}
//============================
void module_reception(){

  while (Serial.available()) {
    char readChar = (char)Serial.read();
    if (readChar == 't'){
    emission();}
  } 
}  
//..................................
void emission(){
  mesure=analogRead(0);
  Serial.print(mesure,DEC);
   Serial.println("%");
  delay(10);
}
//........................

loulou08 forum Panoramic



lundi 11 août 2014

Panoramic pour la robotique


sur le forum Panoramic le 10/08/2014


Jack
Admin

a écrit:


MessageSujet: Re: Pour Noël 2014 ou 2015 Hier à 18:15

Je suis en train de développer (à mon rythme) 4 versions spécialisées de PANORAMIC :
- une version 2D, qui permet de gérer des Sprites, un peu comme avec l'objet SCENE2D, mais en plus complet,
- une version 3D qui gère des objets 3D, comme avec l'objet SCENE3D, mais là aussi en plus complet,
- une version qui gère des bases de données,
- une version spécialisée pour la robotique et les communications.

Dans cette dernière version (robotique/communication), il y aura des commandes permettant d'utiliser des relations serveur/client et de se connecter à internet. Pour l'instant, elle possède des commandes :
- gérant l'interface parallèle (en natif, et non plus and la DLL inpout),
- gérant les liaisons série (elle communique par exemple avec une carte Arduino).
Elle possède aussi de nouveaux objets (LED, BREAKER, KNOB, COLOR_BUTTON) permettant de simuler des faces avant d'appareils de mesure.

Actuellement, je n'ai pas de date de mise à disposition de ces versions spécialisées.
Peut-être pour Noël, 2014 ou ... 2015.
Patience

http://panoramic.free-boards.net/t3733-pour-noel-2014-ou-2015

mercredi 6 août 2014

 Plantage_avec_timer



Quand l'instruction "Timer" fait planter "Panoramic".



Pour simplifier:
  "Timer" est actif à sa création, il appelle le sous-programme.
 Bien avant que le programme le demande ce qui fait planter l'ensemble.

 Dans le code "Panoramic:
' ==========================
  Timer X:Timer_off X
' ========================== 
 Et le programme ne se plante plus.
 Voilà la parade que j'ai trouvé pour éviter ce défaut
loulou08 forum panoramic 

mardi 24 juin 2014

 En modifiant un programme de "papydall  forum Panoramic "
 voici une application de gestion de temps  pour "Panoramic"
  temps entre  " Click "

code

' ###################################################
' Attention panoramique ne gère qu'une seule dll à la fois
' ###################################################
 width 0,200:height 0,150:color 0,200,180,150
 top 0,(screen_y-height(0))/2 :left 0,(screen_x-width(0))/2
 label sp_Click
 dim t% , tickCount%
caption 0,"ges.temps"
 button 1 :left 1,50:top 1,50:caption 1,"Click"
 alpha 2 :left 2,50:top 2,25
 on_click 1,sp_Click
' ====
  end
' ====
sp_Click:
          dll_on "kernel32.dll"
               tickCount% = dll_call0("GetTickCount")
               caption 2, str$(tickCount%-t%)
               t%=tickCount%
          dll_off
return
' ###################################################






mardi 15 avril 2014

Petit rappel

  Avec  la DLL  IO_Acces_Com  trouvée sur le site automatepc

  (IO_Acces_COM.dll  modifiée par Klaus le 9 Avr 2013
  http://panoramic.free-boards.net/t2936-panoramic-arduino)

 Panoramic dialogue   en envoyant et recevant des codes   en caractère "ASCII".
  sur port série RS232 entre PC
  port série virtuel (via connexion USB)
  ou Adaptateur RS232 <-> TTL  pour arduino


 Ouvrir une communication série
 ===================================
 1) dll_on "c:\dll_Panoramic\IO_Acces_COM.dll"

2) a%= dll_call1("ComUsePort",8)

 3) a%= dll_call4("ComConfig",115200,8,1,0)
 ===================================

  Émission série  Tx => Rx
 ===================================
  a%= dll_call1("ComSetDataOut",103)
 ===================================

 Réception série   Rx <= Tx
 ===================================
 a%=DLL_CALL1("ComGetDataIn",adr(dat%))
    WHILE a%>0
        donner$=donner$+chr$(dat%)
        a%=DLL_CALL1("ComGetDataIn",adr(dat%))
    END_WHILE
 ===================================
 Fermetures une communication série
 ===================================
 1) a%= dll_call1("ComUsePort",0)
  "0" permet de refermer le port en cours   d'utilisation.
 2) dll_off
 ===================================



 SainSmart 1.8 ST7735R TFT LCD Module with MicroSD LED 

   http://www.sainsmart.com

https://bitbucket.org/johnmccombs/arduino-libraries/src/64e60d1637398bb8a3c6cb9adb4c7e1fcc07a4bc/ST7735/?at=default 

 


 code  Arduino 


//#define sclk 13    // for MEGAs use pin 52
//#define mosi 11    // for MEGAs use pin 51
#define cs 10   // for MEGAs you probably want this to be pin 53
#define dc 9
#define rst 8  // you can also connect this to the Arduino reset
// couleur definitions
# define NOIR           0x0000
# define BLEU           0xF800 
# define ROUGE          0x001F
# define VERT           0x07E0
# define CYAN           0xFFE0 
# define MAGENTA        0xF81F
# define JAUNE          0x07FF 
# define BLANC          0xFFFF


#include <ST7735.h>
#include <SPI.h>
//ST7735 tft = ST7735(cs, dc, rst);
  ST7735 tft = ST7735(10, 9 ,  8 );
//........................
int x;
int y;
int xx;
int yy;
//.............................
void setup() {

 tft.initR(); // initialize a ST7735R chip
   tft.fillScreen(BLEU);
  tft.drawString(30,20, "PAPY_08", ROUGE ,2);
 delay(4000);
 tft.fillScreen(BLANC);
}
void loop(){
 spcercle();
 delay(4000);
  tft.fillScreen(BLANC);
 spRectangle();
 delay(4000);
  tft.fillScreen(BLANC);
  spligne();
 delay(4000);
  tft.fillScreen(BLANC);
    spligneverticale();
 delay(4000);
  tft.fillScreen(BLANC);
   splignehorizontale();
 delay(4000);
  tft.fillScreen(BLANC);
     spcourbe();
 delay(4000);
  tft.fillScreen(BLANC);
      sptriangle();
 delay(4000);
  tft.fillScreen(BLANC);
}
void spcercle(){
tft.drawString(10,15, "cercle",MAGENTA,2);
tft.drawCircle(70,90, 52,NOIR);//tracer le cercle
tft.fillCircle(70,90, 50,ROUGE);// remplir un Cercle
tft.drawHorizontalLine(70,90,52,NOIR);//Tracer une ligne horizontale
 tft.drawString(60,80, "X,Y   R",JAUNE,1);
}
 void spRectangle(){
 tft.drawString(10,15, "Rectangle",MAGENTA,2); 
tft.fillRect(20,50,70, 50,JAUNE);//remplir Rectangle
tft.drawRect(20,50 ,70,50,VERT);//Dessine un rectangle
tft.drawString(10,40, "X,Y",NOIR,1);
 tft.drawVerticalLine(95,50,50,BLEU);//Tracer une ligne verticale
  tft.drawHorizontalLine(20,130,70,CYAN);//Tracer une ligne horizontale
 tft.drawString(30,110, "Longueur ",MAGENTA,1); 
 tft.drawString(100,75, "Haut",MAGENTA,1); 
 }
void spligne(){
tft.drawString(10,15, "Ligne",MAGENTA,2);
tft.drawLine(20,140,100,40,ROUGE);//tracer une ligne
tft.drawString(10,150, "X,Y",NOIR,1);
tft.drawString(90,30, "X1,Y1",NOIR,1);

void spligneverticale(){
tft.drawString(2,15, "Ligne verticale",MAGENTA,1);
 tft.drawVerticalLine(20,40,70,BLEU);//Tracer une ligne verticale
 tft.drawString(30,50, "Hauteur",MAGENTA,1);
tft.drawString(10,30, "X,Y",NOIR,1);

void splignehorizontale(){
  tft.drawString(2,15, "Ligne horizontale",MAGENTA,1);
 tft.drawHorizontalLine(20,110,80,CYAN);//Tracer une ligne horizontale
 tft.drawString(40,130, "Longueur ",MAGENTA,1); 
tft.drawString(10,120, "X,Y",NOIR,1);
}  
void spcourbe(){
  tft.drawString(2,15, "Courbe",MAGENTA,1);
 x=1;
 y=50;
 xx=1;
 yy=50; 
for (x=1; x <= 120;  x++){
y= random(50, 150);
tft.drawPixel(x, y,NOIR);
tft.drawLine(x,y,xx,yy,ROUGE);//tracer une ligne
xx=x;
yy=y;
delay(10);
}
}
void sptriangle(){
tft.drawString(2,15, "Triangle",MAGENTA,1);
tft.drawVerticalLine(20,40,70,NOIR);//Tracer une ligne verticale
tft.drawHorizontalLine(20,110,80,NOIR);//Tracer une ligne horizontale
tft.drawLine(20,40,100,110,NOIR);//tracer une ligne
}

translate  google