Forums Rue-Montgallet.com
Rue-Montgallet.comRue-Hardware.comRue-Occasion.comRue-DVD.comRue-Jeuxvideo.comRue-AudioVideo.comRue-Telephone.comForums
S'inscrire | S'identifier |
| Recherche avancée | Aide
 
 

Il y a 49 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici

 Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet :

[VC++6] Acquisition de temperature par port serie

 
n°7710
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 28-04-2004 à 10:50:15  profilanswer
 

Salut,(je suis rotcrach un pote a Rantanplan,j'utilise son log)
 
Je dois recupérer les infos d'un capteur de température branché sur mon port serie et j'essaye d'utiliser "_inp" mais cela ne fonctionne pas.
J'ai regardé sur les forums pour voir si je trouvais quelque chose d'intéréssant mais y a pas grand chose!!!
 
la ref du capteur est DS1921 et son support DS9097U de chez ibutton tmex
dallas semiconductor
merci!!!!


Message édité par Rantanplan le 28-04-2004 à 10:51:13
n°7717
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 28-04-2004 à 16:46:31  profilanswer
 

quel OS ?
si c'est 2000 ou XP cherche pas, inp ne fonctionne plus...


Message édité par myst le 28-04-2004 à 16:47:17

---------------
Fondateur de la CuRseD TeAm
n°7718
rotcrash
Profil : Membre
Posté le 28-04-2004 à 17:17:36  profilanswer
 

oui c'est xp, merci quand meme

n°7719
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 28-04-2004 à 18:07:48  profilanswer
 

ben alors pour gerer le port serie sous win t'as 4 fonctions :
CreateFile
ReadFile
WriteFile
CloseHandle
 
et comme nom de fichier tu mets "COM1" "COM2"... etc


---------------
Fondateur de la CuRseD TeAm
n°7723
rotcrash
Profil : Membre
Posté le 28-04-2004 à 19:57:31  profilanswer
 

j'ai fait une fonction qui utilise createfile et readfile mais le probleme c'est que je suis obliger de faire un reset sur le ibutton et ce avec la vitesse de 10473 baud et apres la creation du port j'utilise getcommstate pour regler la vitesse, mais il utilise les vitesse standare en outre 9600 et 14400 mais pas de vitesse intermediaire!!!

n°7724
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 28-04-2004 à 21:06:48  profilanswer
 

euh non tu peux changer la vitesse de connexion
avec le getcommstate tu recupere ta structure DCB qui permet de configurer le port
ensuite tu regles la parametre "BaudRate" de la vitesse dans la structure (et les autres dont t'as besoin par la meme occasion)
puis tu valides par setcommstate...
 
sinon j'ai pas compris l'histoire de ton reset...


---------------
Fondateur de la CuRseD TeAm
n°7728
rotcrash
Profil : Membre
Posté le 28-04-2004 à 23:36:24  profilanswer
 

je suis d'accord avec toi, moi les vitesse attribuer au baudrate son :
CBR_110             CBR_19200  
CBR_300             CBR_38400  
CBR_600             CBR_56000  
CBR_1200           CBR_57600  
CBR_2400           CBR_115200  
CBR_4800           CBR_128000  
CBR_9600           CBR_256000  
CBR_14400  
pour pouvoir aller lire les valeur que j'ai besoin sur mon capteur je dois lui faire un reset et une limite de scrutation pendant un certain temps et ca je doit l'effectuer a la vitesse de 10476, après je peut avoir les valeur voulue a la vitesse de 115200 baud

n°7729
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 29-04-2004 à 08:18:47  profilanswer
 

t'es pas obligé d'utiliser les constantes predefinies, tu peux tres bien affecter ta valeur 10476 à l'attribut BaudRate du DCB... enfin il me semble fortement...
 
par contre desolé mais je comprends tjrs pas grand chose... :/
qu'est ce que tu veux recuperer exactement comme type de donnees ?
comment est ce que t'effectues ta lecture ?
quel est le rythme d'envoi de donnees de ton capteur ?
qu'est ce que t'entend techniquement par "faire un reset" et "limite de scrutation" ?
 
bref qu'est ce que toi t'as fait, et quelle est l'erreur exacte ?


---------------
Fondateur de la CuRseD TeAm
n°7748
rotcrash
Profil : Membre
Posté le 29-04-2004 à 16:24:11  profilanswer
 

lien de mon capteur:
http://www.ibutton.com/ibuttons/DS1921GTransition.html
en gros je doit faire ca,(tirer d'un pdf que j'ai sur le capteur)
 
C. 2. Read Time Slots
Commands and data are sent to iButtons by combining write-0 and write-1 time slots. To read data, the master has to generate read-data time slots to define the start condition of each bit. The read-data time slot looks essentially the same as the write-1 time slot from the master’s point of view. Starting at the high-tolow
transition, the iButton sends 1 bit of its addressed contents. If the data bit is a 1, the iButton leaves the pulse unchanged. If the data bit is a 0, the iButton will pull the data line low for tRDV or 15 µs (Figure 3). In this time frame data is valid for reading by the master. The duration tLOWR of the low pulse sent by
the master should be a minimum of 1 µs with a maximum value as short as possible to maximize the master sampling window. In order to compensate for the cable capacitance of the 1-Wire line the master should sample as close to 15 µs after the synchronization edge as possible. Following tRDV there is an
additional time interval, tRELEASE, after which the iButton releases the 1-Wire line so that its voltage can return to VPULLUP. The duration of tRELEASE may vary from 0 to 45 µs; its nominal value is 15 µs.
 
C. 3. Reset and Presence Detect
The Reset Pulse provides a clear starting condition that supersedes any time slot synchronization. It is defined as a single low pulse of minimum duration of eight time slots or 480 µs followed by a Reset-high time tRSTH of another 480 µs (Figure 4). After a Reset Pulse has been sent, the iButton will wait for the
time tPDH and then generate a Presence Pulse of duration tPDL. No other communication on the 1-Wire bus is allowed during tRSTH. The Presence Pulse can be used to trigger a hardware interrupt or to automatically power up equipment like Touch Pens. If an iButton is disconnected from the probe, it will
pull its data line low via an internal current source of 5 µA. This simulates a Reset Pulse of unlimited duration. As soon as the iButton detects a high level on the data line, it will generate a Presence Pulse.
The nominal values are 30 µs for tPDH and 120 µs for tPDL. With the same worst-case tolerance band, the measured tPDH value indicates the internal time base of the fastest device. The sum of the measured tPDH and tPDL values is five times the internal time base of the slowest device. If there is only one device on the
line, both values will deviate in the same direction. This correlation can be used to build an adaptive system. Special care must be taken to recalibrate timing after every reset since the individual timing characteristics of the devices vary with temperature and load. The accuracy of the time measurements required for adaptive timing is limited by the characteristics of the master’s input logic, the time constant of the 1-Wire line (pullup resistor x cable capacitance) and the
applied sampling rate. If the observed rise time or fall time exceeds 1 µs or the highest possible sampling rate is less than 1 MHz, adaptive timing should not be attempted.

n°7749
rotcrash
Profil : Membre
Posté le 29-04-2004 à 16:26:36  profilanswer
 

Code :
  1. C LANGUAGE FOR UART 8250 SYSTEMS
  2. /*
  3. In the following C language code, 1-wire I/O is accomplished using the serial port of an IBM
  4. PC or compatible. The serial port must be capable of a 115,200 bps data rate. Setup must be
  5. called before any of the touch functions to verify the existence of the specified com port and
  6. initialize it.
  7. -------------------------------------------------------------------------------------------------------------------------------
  8. The setup function makes sure that the com port number passed to it is from 1 to 4 and has a
  9. valid address associated with it.
  10. */
  11. uchar Setup(uchar CmPt)
  12. {
  13. uint far *ptr = (uint far *) 0x00400000;
  14. uint SPA;
  15. /* check to see if it is a valid com port number and address */
  16. SPA = (ptr+CmPt-1); / get the address */
  17. if (CmPt < 1 || CmPt > 4 || !SPA )
  18. return FL;
  19. /* serial port initialization */
  20. outportb(SPA+3,0x83) ; /* set DLAB */
  21. outportb(SPA ,0x01) ; /* bit rate is 115200 */
  22. outportb(SPA+1,0x00) ;
  23. outportb(SPA+3,0x03) ; /* 8 dta, 1 stp, no par */
  24. outportb(SPA+1,0x00) ; /* no interrupts */
  25. outportb(SPA+4,0x03) ; /* RTS and DTR on */
  26. return TR;
  27. }
  28. /*----------------------------------------------------------------------------------------------------------------------------
  29. * Do a reset on the 1 wire port and return 0 no presence detect
  30. * 1 presence pulse no alarm
  31. * 2 alarm followed by presence
  32. * 3 short circuit to ground
  33. * 4 no com port found
  34. *
  35. * The global variable ’com_port’ must be set to the com port that the DS9097 COM Port Adapter is
  36. * attached to before calling this routine.
  37. *
  38. */
  39. uchar TouchReset( void )
  40. {
  41. uint SPA,F,X,Y,tmp,trst=0;
  42. uint far *ptr = (uint far *) 0x00400000;
  43. ulong far *sysclk = (ulong far *) 0x0040006c;
  44. ulong M;
  45. /* get the serial port address */
  46. SPA = *(ptr+com_port-1);
  47. /* return if there is no address */
  48. if (!SPA) return 4;
  49. /* serial port initialization */
  50. outportb(SPA+3,0x83) ; /* set DLAB */
  51. outportb(SPA ,0x01) ; /* bit rate is 115200 */
  52. outportb(SPA+1,0x00) ;
  53. outportb(SPA+3,0x03) ; /* 8 dta, 1 stp, no par */
  54. outportb(SPA+1,0x00) ; /* no interrupts */
  55. outportb(SPA+4,0x03) ; /* RTS and DTR on */
  56. /* Initialize the time limit */
  57. M = *sysclk +1;
  58. /* loop to clear the buffers */
  59. do { tmp = inportb(SPA+5) & 0x60; } while (tmp != 0x60);
  60. /* flush input */
  61. while (inportb(SPA+5) & 0x1) X = inportb(SPA);
  62. outportb(SPA+3,0x83) ; /* set DLAB */
  63. outportb(SPA+1,0x00) ; /* baud rate is 10473 */
  64. outportb(SPA ,0x0B) ;
  65. outportb(SPA+3,0x03) ; /* 8 dta, 1 stp, no par */
  66. outportb(SPA ,0xF0) ; /* send the reset pulse */
  67. /* wait until character back or timeout */
  68. do
  69. {
  70. Y = inportb(SPA+5);
  71. F = Y & 0x1;
  72. } while ( !F && (*sysclk <= M) );
  73. if (F) X = inportb(SPA);
  74. else return 3;
  75. if (X != 0xF0) /* if more bits back than sent then there */
  76. { /* is a device if framing error or break */
  77. trst = TR;
  78. if ( (Y & 0x18) != 0 )
  79. {
  80. trst = 2;
  81. /* loop to clear the buffers */
  82. do { tmp = inportb(SPA+5) & 0x60; } while (tmp != 0x60);
  83. /* wait until character back or timeout */
  84. do
  85. {
  86. Y = inportb(SPA+5);
  87. F = Y & 0x1;
  88. } while ( !F && (*sysclk <= M) );
  89. if (F) X = inportb(SPA);
  90. else return 3;
  91. }
  92. }
  93. outportb(SPA+3,0x83) ; /* set DLAB */
  94. outportb(SPA ,0x01) ; /* bit rate is 115200 */
  95. outportb(SPA+3,0x03) ; /* 8 dta, 1 stp, no par */
  96. return trst;
  97. }
  98. /*----------------------------------------------------------------------------------------------------------------------------
  99. * This is the 1-Wire routine ’TouchByte,’ sometimes called ’DataByte.’ It transmits 8 bits onto the
  100. * 1-Wire data line and receives 8 bits concurrently. The global variable ’com_port’ must be set to
  101. * the com port that the serial brick is attached to before calling this routine. This com port must also
  102. * be set to 115200 baud, 8 dta, 1 stp, and no parity. This routine returns the uchar 8-bit value
  103. * received. If it times out waiting for a character then 0xFF is returned.
  104. */
  105. uchar TouchByte(uchar outch)
  106. {
  107. uchar inch=0,sendbit,Mask=1;
  108. uint SPA;
  109. uint far *ptr = (uint far *) 0x00400000;
  110. ulong far *sysclk = (ulong far *) 0x0040006c;
  111. ulong M;
  112. /* get the serial port address */
  113. SPA = *(ptr+com_port-1);
  114. /* Initialize the time limit */
  115. M = *sysclk +2;
  116. /* wait to TBE and TSRE */
  117. do {} while ( (inportb(SPA+5) & 0x60) != 0x60 );
  118. /* flush input */
  119. while ( (inportb(SPA+5) & 0x1) )
  120. inportb(SPA);
  121. /* get first bit ready to go out */
  122. sendbit = (outch & 0x1) ? 0xFF : 0x00;
  123. /* loop to send and receive 8 bits */
  124. do
  125. {
  126. outportb(SPA,sendbit); /* send out the bit */
  127. /* get next bit ready to go out */
  128. Mask <<= 1;
  129. sendbit = (outch & Mask) ? 0xFF : 0x00;
  130. /* shift input char over ready for next bit */
  131. inch >>= 1;
  132. /* loop to look for the incoming bit */
  133. for (;;)
  134. {
  135. /* return if out of time */
  136. if ( *sysclk > M )
  137. return 0xFF;
  138. if ( inportb(SPA+5) & 0x01 )
  139. {
  140. inch |= ((inportb(SPA) & 0x01) ? 0x80 : 0x00);
  141. break;
  142. }
  143. }
  144. } while (Mask);
  145. return inch; /* return the input char */
  146. }


exemple donner dans le pdf,j'ai essayer de le mettre en oeuvre mais c'est pas formidable,en gros si je pouvais faire la même chose que l'exemple mais avec createfile et readfile ca serai parfait, mais j'ai le proble du baudrate qui me prend la tête


Message édité par rotcrash le 29-04-2004 à 16:30:02
n°7755
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 29-04-2004 à 18:29:03  profilanswer
 

ben pourquoi tu ne changes pas le dcb à chaque fois ?
tu le met a 10473 pour faire ton reset, puis tu le remets à 115200 ensuite ?
ou alors tu te fais pas chier tu lis tout en 10473...
pis qd tu fais pas ton reset mais que tu te contente de lire, il se passe quoi en fait ?
sinon sur ton lien j'ai pas vu pourquoi il est necessaire de faire un reset...
pis tu me dis pas comment est ce que ton capteur envoie les donnees : il envoie tout seul qd ca lui chante, ou sur une requete de ta part ?


---------------
Fondateur de la CuRseD TeAm
n°7758
rotcrash
Profil : Membre
Posté le 29-04-2004 à 20:18:30  profilanswer
 

ok je vais essayé et je te dis quoi par la suite!!! :)


Message édité par rotcrash le 29-04-2004 à 20:18:52
n°7763
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 29-04-2004 à 22:40:44  profilanswer
 

myst a écrit :

quel OS ?
si c'est 2000 ou XP cherche pas, inp ne fonctionne plus...


 
pas d'accord ... moi ma communication série fonctionne avec ça, et je suis sous XP SP1 Pro ;)
 
l'ancien inp est remplacé par _inp, idem pour _outp


---------------
[:rantanplan]
n°7764
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 29-04-2004 à 22:44:24  profilanswer
 

ouais mais meme, inp et outp c'est du C, et la il fait du C++ :o


---------------
Fondateur de la CuRseD TeAm
n°7767
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 29-04-2004 à 23:23:09  profilanswer
 

myst a écrit :

ouais mais meme, inp et outp c'est du C, et la il fait du C++ :o


 
je peux t'assurer qu'en etant mon voisin de paycay en cours, il ne fait pas du CPP :D


---------------
[:rantanplan]
n°7768
rotcrash
Profil : Membre
Posté le 29-04-2004 à 23:34:47  profilanswer
 

:D Merci Retepeu
en faite pour tout dire quand j'utilise _inp ou _outp notre prof a rantanplan et moi meme nous a passé un logiciel qui fait la gestion du port série, ce log c'est direct io, et je dois mettre le lien du .exe dans direct io.
comme ca quand je lance mon prog direct io fais la gestion des entrés sorties!!!


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7769
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 30-04-2004 à 00:01:42  profilanswer
 

Mais de toute facon, que tu utilises _inp/_outp ou les fonctions win, ca revient au meme ... meme si c'est plus chiant d'utiliser les _inp/_outp :)


---------------
[:rantanplan]
n°7770
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 30-04-2004 à 08:58:16  profilanswer
 

justement, pourquoi faire complique quand on peut faire simple :D
 
bon et sinon ca en est ou ton prog du coup ?


---------------
Fondateur de la CuRseD TeAm
n°7783
rotcrash
Profil : Membre
Posté le 01-05-2004 à 11:51:49  profilanswer
 

ca ne donne pas grand chose, je n'arrive a rien,je pense que j'ai trouver une autre méthode pour acquérir mes température!!!
le logiciel fournie avec le capteur cré un fichier ou il met toute les température a l'intérieur,j'ai plus qua les récupérer!!!!


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7784
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 01-05-2004 à 13:41:39  profilanswer
 

mais lol, et tu t'embettais avec le port serie !!! [:bukaroo]


---------------
Fondateur de la CuRseD TeAm
n°7785
rotcrash
Profil : Membre
Posté le 01-05-2004 à 13:47:32  profilanswer
 

c'est claire ,mais jusqu'a hier je savai pas que le prog associer au capteur faisait un fichier avec toute les température :ange:


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7786
rotcrash
Profil : Membre
Posté le 01-05-2004 à 13:47:45  profilanswer
 

rotcrash a écrit :

c'est claire ,mais jusqu'a hier je savai pas que le prog associer au capteur faisait un fichier avec toute les température :ange:  


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7796
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 02-05-2004 à 21:10:57  profilanswer
 

myst a écrit :

mais lol, et tu t'embettais avec le port serie !!! [:bukaroo]


 
ouais mais bon, le but etait quand meme daller recup l'info via le port serie ... m'enfin ... ce qu'il fait est toujours mieux que rien, car l'échéance du projet arrive et vaut mieux avoir un équivalent que rien du tout :)


---------------
[:rantanplan]
n°7797
rotcrash
Profil : Membre
Posté le 02-05-2004 à 22:14:21  profilanswer
 

c'est pas gentil ce que tu dit retepeu!!!!!!!!!!!


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7798
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 02-05-2004 à 22:24:13  profilanswer
 

rotcrash a écrit :

c'est pas gentil ce que tu dit retepeu!!!!!!!!!!!


 
jdis pas ca pour te descendre ;) mais c'est la vérité non ?


---------------
[:rantanplan]
n°7799
rotcrash
Profil : Membre
Posté le 02-05-2004 à 22:40:16  profilanswer
 

oui mais quand même, toi même tu a vue que c'est franchement pas facile a faire!!!!


---------------
IBM T41p POWAAA!!!
Bientot a moi j'espère
n°7801
Rantanplan
Modo pas rigolo !
Profil : Fossile
Posté le 02-05-2004 à 22:50:13  profilanswer
 

rotcrash a écrit :

oui mais quand même, toi même tu a vue que c'est franchement pas facile a faire!!!!


 
bah oui j'ai vu ! et je ne te critique pas ! moi-même j'aurai surement fait ça ;)


---------------
[:rantanplan]
n°7806
myst
nono powered ©
Profil : Vieux de la vieille
Posté le 03-05-2004 à 12:48:37  profilanswer
 

moi j'aurais pas utilise inp et outp :D :p


Message édité par myst le 03-05-2004 à 12:48:55

---------------
Fondateur de la CuRseD TeAm

Aller à :
Ajouter une réponse