Autor Tema: Mis experiencias con el BUS CAN  (Leído 892261 veces)

0 Usuarios y 3 Visitantes están viendo este tema.

Desconectado electrolinux

  • PIC12
  • **
  • Mensajes: 93
Re: Mis experiencias con el BUS CAN
« Respuesta #360 en: 13 de Marzo de 2008, 17:18:27 »
No son opciones los basados en semiconductores ya que la temperatura a medir es del orden de los 230grC.... es decir no operan a esas temperaturas. Es por eso que debe ser una PT100.

Saludos

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado electrolinux

  • PIC12
  • **
  • Mensajes: 93
Re: Mis experiencias con el BUS CAN
« Respuesta #362 en: 13 de Marzo de 2008, 19:35:09 »
Gracias quirogaareal:

Pues si me sirve... y agradecipor por tu tiempo y ayuda.

Saludos

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #363 en: 16 de Marzo de 2008, 18:05:41 »
Hola Muchachos :

Aca hay un poco mas de bus can , espero que contribuya en algo mas.

Saludos desde Cordoba Argentina
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #364 en: 16 de Marzo de 2008, 18:06:23 »
La parte que sigue
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #365 en: 16 de Marzo de 2008, 18:06:58 »
la ultima parte
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado MGLSOFT

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 7907
Re: Mis experiencias con el BUS CAN
« Respuesta #366 en: 16 de Marzo de 2008, 21:55:54 »
Gracias por compartirlo!! :lol:
Todos los dias aprendo algo nuevo, el ultimo día de mi vida aprenderé a morir....
Mi Abuelo.

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #367 en: 17 de Marzo de 2008, 18:05:14 »
Uno se alegra de haber sido util.

DND

Saludos desde Cordoba Argentina
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado MGLSOFT

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 7907
Re: Mis experiencias con el BUS CAN
« Respuesta #368 en: 17 de Marzo de 2008, 18:32:47 »
Este es para comentarles de mis avances, tengo lista y probada 100% la placa del sniffer CAN (falta el software por supuesto) y tambien los modulos CAN de Pierno10 funcionando y conectados al Bus CAN.
A la brevedad pondre fotos aqui para compartirlas... :mrgreen:
Todos los dias aprendo algo nuevo, el ultimo día de mi vida aprenderé a morir....
Mi Abuelo.

Desconectado marcos P.J

  • PIC10
  • *
  • Mensajes: 12
Re: Mis experiencias con el BUS CAN
« Respuesta #369 en: 19 de Marzo de 2008, 11:49:43 »
Hola, estoy avanzando rapidamente en mi placa de buscan y mientras acabo de retocarla estoy empezando a programar en el mplab y me sale este error¡¡ alguien me podria decir a que se debe?¿
en breve colgare el circuito de prueva, que consta de una nodo esclavo y uno master¡¡
gracias

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Archivos de programa\PICC\Ccsc.exe" Marcos.c
Error[24]   C:\Archivos de programa\PICC\devices\18F458.h 2 : Unknown device type    -- Try PCH
Halting build on first failed translation as user preferences indicate.
BUILD FAILED: Wed Mar 19 15:46:31 2008

Desconectado MGLSOFT

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 7907
Re: Mis experiencias con el BUS CAN
« Respuesta #370 en: 19 de Marzo de 2008, 21:37:04 »
Explicanos un poco mas de que compilador se trata, como lo tienes configurado y si lo que quieres es simularlo en MPLAB.
Asi podremos ayudarte mas, ya que con solo esto no creo poderlo hacer...
Ademas si puedes pon el codigo de ambos asi podremos darte mas ayuda.. :mrgreen:
Todos los dias aprendo algo nuevo, el ultimo día de mi vida aprenderé a morir....
Mi Abuelo.

Desconectado Leon Pic

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3610
    • Impresiones en 3D
Re: Mis experiencias con el BUS CAN
« Respuesta #371 en: 20 de Marzo de 2008, 10:51:03 »
Si le hacés doble clic en el error, te lleva al lugar del problema.

mmmmmmmmmmmm. Me parece que tenes mal configurado el mplab. Lo que dice que el dispotivo 18F458.h 2 es desconocido. Ese 2, me parece que está mal.
Jesús dijo, yo soy el CAMINO, la VERDAD y la VIDA, nadie llega al PADRE si no es por mi.

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #372 en: 22 de Marzo de 2008, 07:42:16 »
Hola MGLSFT:

En que parte del programa del nodo A defines la velocidad del bus can?
Controlas tu placa tambien desde el teclado de la pc o solo usas el rs232 para monitorear el bus ?


Saludos
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina

Desconectado MGLSOFT

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 7907
Re: Mis experiencias con el BUS CAN
« Respuesta #373 en: 22 de Marzo de 2008, 21:29:58 »
Hola MGLSFT:

En que parte del programa del nodo A defines la velocidad del bus can?
Controlas tu placa tambien desde el teclado de la pc o solo usas el rs232 para monitorear el bus ?


Saludos

La velocidad se define, disculpando la rebuznancia, con el define antes de llamar a la rutina de configuracion del bus can
el rs232 es para monitoreo y debug. :mrgreen:
Todos los dias aprendo algo nuevo, el ultimo día de mi vida aprenderé a morir....
Mi Abuelo.

Desconectado quirogaareal

  • PIC16
  • ***
  • Mensajes: 180
Re: Mis experiencias con el BUS CAN
« Respuesta #374 en: 25 de Marzo de 2008, 23:05:58 »
Hola MGLSOFT:

Aca te adjunto una copia del primer programa que posteaste (NODO A)

la verdad que no encuentro donde definiste la velocidad ?

Código: C
  1. /////////////////////////////////////////////////////////////////////////
  2. ////                         EX_CAN_CCS_A_4580.C                     ////
  3. ////                                                                 ////
  4. //// Example of CCS's CAN library, using the PIC18Fxx8.  This        ////
  5. //// example was tested with and written for the CCS CAN Prototype   ////
  6. //// board.                                                          ////
  7. ////                                                                 ////
  8. //// The CCS CAN Prototype board has four CAN nodes that communicate ////
  9. //// to each other.  Node A is the 18F458 with it's internal CAN     ////
  10. //// peripheral, Node B is a PIC16F87x connected to an external      ////
  11. //// MCP2510 CAN peripheral, and Node C and Node D are both MCP250xx ////
  12. //// stand-alone CAN I/O expanders.  This example is the firmware    ////
  13. //// for Node A.                                                     ////
  14. ////                                                                 ////
  15. //// Every two seconds this firmware sends out a command to node B   ////
  16. //// to change it's leds (CAN ID 0x202)                              ////
  17. ////                                                                 ////
  18. //// Upon change of the A/D reading, a value of 0-9 is sent to       ////
  19. //// Node D which is displayed on the 8-seg LCD (CAN ID 0x400)       ////
  20. ////                                                                 ////
  21. //// Pressing the Node A button sends a request to Node B (CAN ID    ////
  22. //// 0x201) for Node B's A/D reading, which Node B will respond      ////
  23. //// with a CAN message with it's A/D reading (with CAN ID 0x201).   ////
  24. //// Also, pressing the Node A button will change the LEDs on Node   ////
  25. //// C (CAN ID 0x300)                                                ////
  26. ////                                                                 ////
  27. //// Pressing Node C's buttons will cause Node A's buttons to change ////
  28. //// (Node C transmits button changes with CAN ID 0x303)             ////
  29. ////                                                                 ////
  30. //// Using a serial port, you can examine all the CAN traffic as     ////
  31. //// seen by the 18xxx8.                                             ////
  32. ////                                                                 ////
  33. //// For more documentation on the CCS CAN library, see can-18xxx8.c ////
  34. ////                                                                 ////
  35. ////  Jumpers:                                                       ////
  36. ////     PCH    pin C7 to RS232 RX, pin C6 to RS232 TX               ////
  37. ////                                                                 ////
  38. ////  This example will work with the PCH compiler.                  ////
  39. /////////////////////////////////////////////////////////////////////////
  40. ////                                                                 ////
  41. //// Baud rate settings to use to connect to the CCS CAN Prototype   ////
  42. //// board at 20Mhz:                                                 ////
  43. ////                                                                 ////
  44. ////    Baud Rate Prescalar: 4                                       ////
  45. ////    Propagation Segment: 3xTq                                    ////
  46. ////    Phase Segment 1: 6xTq                                        ////
  47. ////    Phase Segment 2: 6xTq                                        ////
  48. ////    Synchronized Jump Width: 1xTq                                ////
  49. ////    Sample Rate: 1x                                              ////
  50. ////    Wakeup Filter:  Off                                          ////
  51. ////                                                                 ////
  52. /////////////////////////////////////////////////////////////////////////
  53. ////                                                                 ////
  54. //// Node C and D are seperate stand-alone MCP250xx CAN I/O          ////
  55. //// expanders.  The CCS CAN Prototype board has these chips already ////
  56. //// programmed correctly.  However, if you wish to program your own ////
  57. //// to work with this example, then use the provided .HEX files     ////
  58. //// a programmer capable of programming these chips.  Or, make a    ////
  59. //// a new HEX file with these properties:                           ////
  60. ////                                                                 ////
  61. //// NODE C: Set RX ID mask and buffers to receive ID 0x3**. (The ** ////
  62. //// means make the least signifcant 8bits no-care in the mask).     ////
  63. //// Set TX1 buffer to ID 0x301, TX2 buffer to ID 0x302, TX3 buffer  ////
  64. //// to ID 0x303. Set GP0 to analog (and enable the A/D).  Set GP1,  ////
  65. //// GP2 and GP3 to OUTPUT.  Set GP4, GP5 and GP6 as INPUT with edge ////
  66. //// trigger enable.  Leave OPTREG2 clear, disable PWM1 and PWM2,    ////
  67. //// and disable scheduled transmission.  Also, see the baud rate    ////
  68. //// settings above.                                                 ////
  69. ////                                                                 ////
  70. //// NODE D: Set RX ID mask and buffers to receive ID 0x4**. (The ** ////
  71. //// means make the least signifcant 8bits no-care in the mask).     ////
  72. //// Set TX1 buffer to ID 0x401, TX2 buffer to ID 0x402, TX3 buffer  ////
  73. //// to ID 0x403. Configure all ports as OUTPUT.  Leave OPTREG2      ////
  74. //// clear, disable PWM1 and PWM2, and disable scheduled             ////
  75. //// transmission.  Also, see the baud rate settings above.          ////
  76. ////                                                                 ////
  77. /////////////////////////////////////////////////////////////////////////
  78. ////        (C) Copyright 1996,2003 Custom Computer Services         ////
  79. //// This source code may only be used by licensed users of the CCS  ////
  80. //// C compiler.  This source code may only be distributed to other  ////
  81. //// licensed users of the CCS C compiler.  No other use,            ////
  82. //// reproduction or distribution is permitted without written       ////
  83. //// permission.  Derivative programs created using this software    ////
  84. //// in object code form are not restricted in any way.              ////
  85. /////////////////////////////////////////////////////////////////////////
  86.  
  87. #include <18F4580.h>
  88. #device ICD=TRUE
  89. #device adc=8
  90.  
  91. #FUSES NOWDT                    //No Watch Dog Timer
  92. #FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
  93. #FUSES HS                       //High speed Osc (> 4mhz)
  94. #FUSES NOPROTECT                //Code not protected from reading
  95. #FUSES BROWNOUT                 //Reset when brownout detected
  96. #FUSES BORV21                   //Brownout reset at 2.1V
  97. #FUSES PUT                      //Power Up Timer
  98. #FUSES NOCPD                    //No EE protection
  99. #FUSES STVREN                   //Stack full/underflow will cause reset
  100. #FUSES NODEBUG                  //No Debug mode for ICD
  101. #FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
  102. #FUSES NOWRT                    //Program memory not write protected
  103. #FUSES NOWRTD                   //Data EEPROM not write protected
  104. #FUSES NOIESO                     //Internal External Switch Over mode enabled
  105. #FUSES FCMEN                    //Fail-safe clock monitor enabled
  106. #FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
  107. #FUSES BBSIZ1K                  //1K words Boot Block size
  108. #FUSES NOWRTC                   //configuration not registers write protected
  109. #FUSES NOWRTB                   //Boot block not write protected
  110. #FUSES NOEBTR                   //Memory not protected from table reads
  111. #FUSES NOEBTRB                  //Boot block not protected from table reads
  112. #FUSES NOCPB                    //No Boot Block code protection
  113. #FUSES NOLPT1OSC              //Timer1 is not configured for low-power operation
  114. #FUSES MCLR                     //Master Clear pin enabled
  115. #FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
  116.  
  117. //#include <18F4580.h>
  118. //#fuses HS,NOPROTECT,NOLVP,NOWDT
  119. #use delay(clock=10000000)
  120. #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
  121.  
  122. #define CAN_DO_DEBUG TRUE
  123.  
  124. #define Set_250K_Baud TRUE  /// Aqui configuro que velocidad del BUS utilizo
  125.  
  126. #include "can-18F4580.c"
  127.  
  128. #include <lcd.c>
  129.  
  130. #define PIN_LED1  PIN_E2
  131. #define PIN_LED2  PIN_E0
  132. #define PIN_LED3  PIN_E1
  133.  
  134. #define LED1_LOW  output_low(PIN_LED1)
  135. #define LED1_HIGH output_high(PIN_LED1)
  136. #define LED2_LOW  output_low(PIN_LED2)
  137. #define LED2_HIGH output_high(PIN_LED2)
  138. #define LED3_LOW  output_low(PIN_LED3)
  139. #define LED3_HIGH output_high(PIN_LED3)
  140.  
  141. #define BOTON_ENTER  PIN_A5
  142. #define BOTON_ESC    PIN_A4
  143. #define BOTON_PROG   PIN_A3
  144. #define BOTON_UP     PIN_A2
  145. #define BOTON_DOWN   PIN_A1
  146.  
  147. #define BOTON_ENTER_PRES   !input(BOTON_ENTER)
  148. #define BOTON_ESC_PRES     !input(BOTON_ESC)
  149. #define BOTON_PROG_PRES    !input(BOTON_PROG)
  150. #define BOTON_UP_PRES      !input(BOTON_UP)
  151. #define BOTON_DOWN_PRES    !input(BOTON_DOWN)
  152.  
  153. int16 ms;
  154.  
  155. const char lcd_seg[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x21,0x06,0x0E};   //0 for on, 1 for off
  156.  
  157. #int_timer2
  158. void isr_timer2(void) {
  159.    ms++; //keep a running timer that increments every milli-second
  160. }
  161.  
  162. #define ASK_FOR_ID_AD_B      0x201  //ask for AD info from CAN port B
  163. #define SET_LED_ID_B         0x202  //set LEDs for CAN port B
  164. #define RESPOND_TO_LED_C_ID  0x303
  165. #define WRITE_REGISTER_C_ID  0x300
  166. #define WRITE_REGISTER_D_ID  0x80400
  167. #define WRITE_PWM2_D_ID      0x301
  168.  
  169. void main() {
  170.    int b_leds=0;
  171.    int c_leds=1;
  172.    int a_leds=0;
  173.    int AD_NodoB=0;
  174.    struct rx_stat rxstat;
  175.    int32 rx_id;
  176.    int buffer[8];
  177.    int rx_len;
  178.  
  179.    int last_lcd_output=0xFF;
  180.    int i,curr_lcd_output;
  181.  
  182.    int16 curr_pwm2_duty, last_pwm2_duty;
  183.    int byte8_2_pwm2, byte1_0_pwm2;
  184.  
  185.    setup_port_a(AN0);
  186.    setup_adc(ADC_CLOCK_INTERNAL);
  187.    set_adc_channel(0);
  188.  
  189.    for(i=0;i<8;i++) {
  190.       buffer[i]=0;
  191.    }
  192.  
  193.    LED1_HIGH;
  194.    LED2_HIGH;
  195.    LED3_HIGH;
  196.    printf("\r\n\r\nEjemplo CAN CCS\r\n");
  197.    delay_ms(1000);
  198.    LED1_LOW;
  199.    LED2_LOW;
  200.    LED3_LOW;
  201.  
  202.    setup_timer_2(T2_DIV_BY_16,53,3);   //setup up timer2 to interrupt every 1ms if using 20Mhz clock
  203.  
  204.    lcd_init();
  205.    can_init();
  206.    lcd_putc("\f"); //borrar display
  207.  
  208.    enable_interrupts(INT_TIMER2);
  209.    enable_interrupts(GLOBAL);
  210.  
  211.    printf("\r\nMarchando...");
  212.  
  213.    lcd_gotoxy(1,1);
  214.    lcd_putc("Marchando..."); ///escribo en el LCD
  215.    lcd_gotoxy(1,2);
  216.    lcd_putc("GRACIAS ARIEL!!!"); ///escribo en el LCD
  217.  
  218.    while(TRUE)
  219.    {
  220.       if ( can_kbhit() )
  221.       {
  222.          printf("\r\n");
  223.          if(can_getd(rx_id, &buffer[0], rx_len, rxstat)) {
  224.             if (rx_id == ASK_FOR_ID_AD_B) {
  225.                printf("Conversión AD Nodo B: %X\r\n",buffer[0]);
  226.                AD_NodoB = buffer[0];  //guardo valor del conversor AD
  227.             }
  228.             else if (rx_id == RESPOND_TO_LED_C_ID) {  //nodo C es un mcp25050 que envía un a mensaje ante la deteccion de un flanco
  229.                printf("Cambiando LEDs\r\n");            //in_data[0]=iointfl, in_data[1]=gpio
  230.                a_leds=(buffer[0]);
  231.                //a_leds=~(buffer[1]);  //cambiado para poder leer los bits enviados desde Nodo B
  232.                if (bit_test(a_leds,0)) {LED1_HIGH;} else {LED1_LOW;}
  233.                if (bit_test(a_leds,1)) {LED2_HIGH;} else {LED2_LOW;}   //idem anterior
  234.                if (bit_test(a_leds,2)) {LED3_HIGH;} else {LED3_LOW;}
  235.  
  236.             }
  237.          }
  238.       }
  239.  
  240.       if ( can_tbe() && (ms > 2000))       //every two seconds, send new data if transmit buffer is empty
  241.       {
  242.          ms=0;
  243.  
  244.          //change leds on port b
  245.          printf("\r\n\r\nEscribe LEDs en Nodo B a %U",b_leds);
  246.          can_putd(SET_LED_ID_B, &b_leds, 1, 1, 1, 0);
  247.          /* if (bit_test(b_leds,0)) {LED1_HIGH;} else {LED1_LOW;}
  248.           if (bit_test(b_leds,1)) {LED2_HIGH;} else {LED2_LOW;}      //envio el dato a mis leds
  249.           if (bit_test(b_leds,2)) {LED3_HIGH;} else {LED3_LOW;}*/
  250.  
  251.                lcd_putc("\f"); //borrar display
  252.                printf(lcd_putc,"Leds Nodo B : %02u",b_leds); ///escribo en el LCD
  253.                lcd_gotoxy(1,2);
  254.                printf(lcd_putc,"Dato Conv.AD:%03u",AD_NodoB); ///escribo en el LCD
  255.  
  256.          b_leds++;
  257.          if (b_leds > 7) {b_leds=0;}
  258.  
  259.          // cuenta para enviar al nodo D
  260.          curr_lcd_output++;
  261.          if (curr_lcd_output > 15) {curr_lcd_output=0;}
  262.       }
  263.  
  264.       if (BOTON_ESC_PRES) {
  265.          while (BOTON_ESC_PRES) {}
  266.          delay_ms(200);
  267.  
  268.          //ask for AD on port B
  269.          printf("\r\n\r\nPidiendo lectura conversor A/D en Nodo B...");
  270.          can_putd(ASK_FOR_ID_AD_B, 0, 1, 1, 1, 1);
  271.  
  272.          //change LEDs on port C
  273.          buffer[0]=0x1E;            //addr of gplat on 25050
  274.          buffer[1]=0x0E;            //mask
  275.         // buffer[2]=~(c_leds << 1);  //new gplat
  276.          buffer[2]=(c_leds << 1);  //new gplat values
  277.          printf("\r\nIncrementar LED en Nodo C");
  278.          can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
  279.          c_leds++;
  280.          if (c_leds > 7) {c_leds=0;}
  281.       }
  282.  
  283.       if (BOTON_PROG_PRES) {  // APAGAR EL PWM 2
  284.          while (BOTON_PROG_PRES) {}
  285.          delay_ms(100);
  286.  
  287.          //Reprogramar el MCP25050 del Nodo C a todo salida digital
  288.          printf("\r\n\r\nReprogramando el Nodo C...");
  289.             buffer[0]=0x22;                    //direccion de timer de pwm2
  290.             buffer[1]=0x80;                     //mask
  291.             buffer[2]=0x00;                //apagar el timer de pwm2
  292.             can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
  293.       }
  294.      
  295.       if (BOTON_DOWN_PRES) {  // ENCENDER EL PWM 2
  296.          while (BOTON_DOWN_PRES) {}
  297.          delay_ms(100);
  298.  
  299.          //Reprogramar el MCP25050 del Nodo C a PWM2
  300.          printf("\r\n\r\nReprogramando el Nodo C...");
  301.             buffer[0]=0x22;                    //direccion de timer de pwm2
  302.             buffer[1]=0x80;                     //mask
  303.             buffer[2]=0x80;                //apagar el timer de pwm2
  304.             can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
  305.       }
  306.  
  307.          //change lcd segment on port d
  308.          i=read_adc();
  309.         // curr_lcd_output=i/26;   //scale to 0-9
  310.  
  311.          if (curr_lcd_output != last_lcd_output) {
  312.             last_lcd_output=curr_lcd_output;
  313.             printf("\r\nCambiando Display 7-seg Nodo D a cuentas del canal A/D (%X, %X)",i,curr_lcd_output);
  314.             buffer[0]=0x1E;                    //addr of gplat
  315.             buffer[1]=0x7F;             //mask
  316.             buffer[2]=lcd_seg[curr_lcd_output];                //new gplat values
  317.             can_putd(WRITE_REGISTER_D_ID, &buffer[0], 3, 1, 1, 0);
  318.          }
  319. // escribe nuevo valor en PWM2 Nodo C
  320.          if (curr_pwm2_duty != last_pwm2_duty) {
  321.             last_pwm2_duty=curr_pwm2_duty;
  322.             printf("\r\nCambiando Display 7-seg Nodo D a cuentas del canal A/D (%X, %X)",i,curr_lcd_output);
  323.             // Escribe los 8 bits altos del PWM2
  324.             byte1_0_pwm2= MAKE8((curr_pwm2_duty & 0x03),0);  //carga el valor del byte bajo
  325.             byte8_2_pwm2= MAKE8((curr_pwm2_duty << 6),1);  //carga el valor del byte alto
  326.                        
  327.             buffer[0]=0x26;                    //direccion de valor de pwm2
  328.             buffer[1]=0xFF;             //mask
  329.             buffer[2]=byte8_2_pwm2;                //new pwm2 values
  330.             can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
  331.             // Escribe los 2 bits bajos del PWM2
  332.             buffer[0]=0x22;                    //direccion de timer de pwm2
  333.             buffer[1]=0x03;             //mask
  334.             buffer[2]=byte1_0_pwm2;                //new pwm2 values
  335.             can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
  336.          }
  337.          if ((curr_pwm2_duty += 5) > 1023) {curr_pwm2_duty=0;}
  338.    }
  339. }

Nota:
Perdon por modificar tu codigo, pero es la forma de ordenar y a la vez mostrarte donde lo configuro, es en la linea...
Código: C
  1. #define Set_250K_Baud TRUE  /// Aqui configuro que velocidad del BUS utilizo
« Última modificación: 26 de Marzo de 2008, 08:24:23 por MGLSOFT »
Recuerda : Si una mujer te ama de verdad no te pedira ni Matrimonio, Ni concubinato , Ni hijos, No te mentira , ni buscara que cambies de opinion con respecto a las tres primeras opciones.

Saludos

desde Cordoba Argentina


 

anything