Jump to content
43oh

zeke

Members
  • Content Count

    1,782
  • Joined

  • Last visited

  • Days Won

    102

Reputation Activity

  1. Like
    zeke reacted to EngIP in POV with G2211 and little else   
    Just a little update with this "project".
     
    I put the circuit on stripboard, a bit easier than frantically swinging a breadboard about in my efforts to impress the wife.
     

     
    A few attempts at more than a pretty green face...
     

     
    An attempt at mixing inverse and regular text...Not great
     

     
    About the best picture I managed to get...
     

  2. Like
    zeke got a reaction from bluehash in Floating CCS License   
    I was looking for a way to convert my node locked CCS license into a floating license when I stumbled across a really good idea.
     
    This article on e2e suggests a novel way of using a node locked license as a pseudo-floating license using a USB WLAN stick.
     
    The node lock uses the PC's ethernet MAC address. If you use a USB WLAN stick then you can move that stick from PC to Laptop without any licensing issues. Cool!
     
    Time to go and get a USB WLAN stick.

  3. Like
    zeke got a reaction from jsolarski in Programmable load begging for an MSP430 mod   
    I was reading Dangerous Prototypes newsfeed this morning and I spotted a link to a programmable load article.
     
    This may be a useful product for someone out there doing a power supply project. Had I won a recent contract bid :cry: , it would have been infinitely useful to me for my product torture testing phase. I would have been able to dynamically and remotely adjust the load on the power supplies inside of a temperature testing chamber.
     
    Since the project is open source, I thought I should mention it here. It's not based on an MSP430 but I suspect that it could be modified appropriately
  4. Like
    zeke got a reaction from Rickta59 in Any Entrepreneurs hanging out here?   
    I was wondering if any Entrepreneurs / Small Business Owners hang out here?
     
    If so, tell me what you think of Rob Walling's article The Micropreneur's Manifesto.
     
    I read it tonight and thought it had a lot of interesting points. I'm personally trying to make #5 happen right now. I guess I'm reacting to all of this Maker Revolution happening around us.
  5. Like
    zeke reacted to fj604 in State Machine-based Pedestrian Crossing Simulator   
    As promised: a pedestrian crossing simulator - requires a 74HC595 shift register (though I could have done this without it)
     

    /* * State Machine demo for MSP430 * Simulates a UK pedestrian crossing with sound * http://en.wikipedia.org/wiki/Pelican_crossing * Requires a 74HC595 shift register and an optional piezo speaker * WDT timer is used to control traffic light phases and beeps * Timer_A0 used as a beep frequency generator */ #include #define TF 23 // Approx. WDT ticks per second // Pin definitions // 74HC595: Data - P1.4, Clock = P1.5, Latch = P1.2 #define PIN_DATA BIT4 #define PIN_CLOCK BIT5 #define PIN_LATCH BIT2 // Pedestrian button on P1.7 #define PIN_BUTTON BIT7 // Piezo speaker on P1.1 #define PIN_SPEAKER BIT1 // LED connections for 74HC595 // T = traffic, P = pedestrian #define T_RED BIT0 #define T_AMBER BIT1 #define T_GREEN BIT2 #define P_RED BIT3 #define P_GREEN BIT4 #define P_WAIT BIT5 #define DEL_P_MIN TF*20 // Minimum time for traffic to stay green #define DEL_T_AMBER TF*2 // Traffic amber phase #define DEL_T_RED TF*2 // Traffic red phase #define DEL_P_GREEN TF*8 // Pedestrian green phase #define DEL_P_GREEN_FLASH TF*4 // Pedestrian green / traffic amber flashing phase #define FREQ 4000 // Beep frequency x 2 #define BEEP_D 3 // Beep duration in ticks #define FLASH_D 10 // Flash duration in ticks #define SMCLK 1000000 // SMCLK frequency static enum { INIT = 0, // Init phase TRAF_GREEN = 1, // Traffic green PED_WAITING = 2, // Pedestrian waiting TRAF_AMBER = 3, // Traffic amber, pedestrian red TRAF_RED = 4, // Traffic red, pedestrian red PED_GREEN = 5, // Traffic red, pedestrian green PED_GREEN_FLASH = 6 // Traffic amber flashing, pedestrian green flashing } state=INIT; unsigned char lights=0, button=0; void main(void) { // Set up timers // WDT used for light phases and timing beeps // Timer_A used for beeps frequency BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; BCSCTL3 |= LFXT1S_2; // 12khz VLOCLK for ACLK WDTCTL = WDTPW | WDTTMSEL | WDTSSEL | WDTIS1; // Interval timer mode, ACLK, // 12 khz / 512 ~ 23 Hz IE1 |= WDTIE; // Enable WDT interrupt P1SEL |= PIN_SPEAKER; // PIN_SPEAKER to alternative output (CO0) TACCTL0 = OUTMOD_0; // OUT output mode TACCR0 = SMCLK / FREQ; // Set beep frequency TACTL = TASSEL_2 | MC_0; // SMCLK, stop timer // Set up interrupt for button P1OUT &= ~PIN_BUTTON; // Pull button pin down P1REN = PIN_BUTTON; // Enable resistor on button pin P1IES &= ~PIN_BUTTON; // Lo/Hi Edge P1IE |= PIN_BUTTON; // Enable interrupt P1IFG &= ~PIN_BUTTON; // Clear interrupt flag P1DIR |= PIN_DATA | PIN_CLOCK | PIN_LATCH | PIN_SPEAKER; _enable_interrupts(); _low_power_mode_0(); } #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void) { static unsigned int ticks=0, wait=0; unsigned char new_lights = lights; ticks++; if (wait) wait--; switch (state) { case INIT: // First cycle - initialize lights new_lights = T_GREEN | P_RED; // Traffic green, Pedestrian red state = TRAF_GREEN; break; case TRAF_GREEN: if (button) // If button was pressed { button = 0; // Reset button flag new_lights |= P_WAIT; // Pedestrian wait light on state = PED_WAITING; } break; case PED_WAITING: if (wait == 0) // If interval expired { new_lights = T_AMBER | P_RED | P_WAIT; // Traffic amber, Pedestrian red + wait wait = DEL_T_AMBER; // Wait for traffic amber phase state = TRAF_AMBER; } break; case TRAF_AMBER: if (wait == 0) // If interval expired { new_lights = T_RED | P_RED | P_WAIT; wait = DEL_T_RED; state = TRAF_RED; } break; case TRAF_RED: if (wait == 0) { new_lights = T_RED | P_GREEN; wait = DEL_P_GREEN; TACTL |= MC_1; // start timer to sound beeps state = PED_GREEN; } break; case PED_GREEN: if (ticks % BEEP_D == 0) TACCTL0 ^= OUTMOD_4; // Toggle TimerA output mode OUT/Toggle for intermittent beeps if (wait == 0) { wait = DEL_P_GREEN_FLASH; state = PED_GREEN_FLASH; new_lights = T_AMBER | P_GREEN; TACTL &= ~MC_1; // stop timer - disable beeps } break; case PED_GREEN_FLASH: if (ticks % FLASH_D == 0) new_lights ^= T_AMBER | P_GREEN; // Toggle Traffic Amber + Pedestrian Green if (wait == 0) { new_lights = T_GREEN | P_RED; wait = DEL_P_MIN; button = 0; state = TRAF_GREEN; } break; } if (lights != new_lights) // Shift out new lights to 74HC595 { unsigned char b; P1OUT &= ~PIN_LATCH; // latch to low lights = new_lights; for (b=0; b<8; b++) { P1OUT &= ~PIN_CLOCK; // clock to low if (lights & (BIT7 >> ) // if bit is set P1OUT |= PIN_DATA; // data pin to high else P1OUT &= ~PIN_DATA; // data pin to low P1OUT |= PIN_CLOCK; // clock to high } P1OUT |= PIN_LATCH; // latch to high } } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { button = 1; P1IFG &= ~PIN_BUTTON; // P1.4 IFG cleared }
  6. Like
    zeke got a reaction from jsolarski in I know this is oooooold... but still funny   
    I know this video is old but I still think it's hilarious:
     
    Weird Al - White and Nerdy.
     
    I think Donny Osmond is pretty funny in
    .
  7. Like
    zeke got a reaction from jsolarski in State Machine Example Code   
    Hi Guys,
     
    I've been thinking about the topic of state machines lately and I thought I'd try to whip up a posting on my approach to state machines.
     
    I've written a state machine for my client but I can't post that without a lot of changes. So I'm going to convert it into a traffic light state machine example.
     
    Hmmm... I just realized that I should talk about what a state machine is but I haven't got anything prepared yet. So, for now, I'll assume you know what it is.
     
    Here's my definitions and declarations:
     

    #include // add header file for MSP430G2231 device. #include #define VERSION(id, rev, tag) const char id##_version[] = "@(#)Id:" #id " Ver:" rev " Released by:" tag " Built:" __DATE__ " " __TIME__ #define INPUT 0 #define OUTPUT 1 #define TRUE 1 #define FALSE 0 #define HIGH 1 #define LOW 0 #define TOGGLE 2 #define nothing1 BIT0 // P1.0, 0x01, 0b0000 0001 #define onGREENLED BIT1 // P1.1, 0x02, 0b0000 1000 #define onREDLED BIT2 // P1.2, 0x04, 0b0001 0000 #define nothing2 BIT3 // P1.3, 0x08, 0b0000 0010 #define nothing3 BIT4 // P1.4, 0x10, 0b0000 0100 #define onYELLOWLED BIT5 // P1.5, 0x20, 0b0010 0000 #define nothing4 BIT6 // P1.6, 0x40, 0b0100 0000 #define nothing5 BIT7 // P1.7, 0x80, 0b1000 0000 #define TIMEBASE 16384 // This is selected ACLK/2, Production value = 16384 #define STARTTIMEOUT 5 // 5 seconds #define OVERALLTIMEOUT 43200 // 12hr*60min*60sec = 43200 seconds /******************************************************************************* * Global Variables * ******************************************************************************/ unsigned char TimerTick;
     
     
     
    So, here's my main function and interrupt routine. This will configure the msp430 to interrupt every TIMEBASE counts. In this case, the result is an interrupt every 0.25 seconds.
     

    void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; BCSCTL3 |= XCAP_3; // Launchpad watch crystals need ~12.5 pF // Configure all IO's and their default states on the MSP430 InitMSP430(); InitIOs(); // Initialize the system tick count TimerTick = 0; // Initialize all state machines InitTimerStateMachine(); InitTrafficLightStateMachine(); VERSION(TrafficLightStateMachineExample, "Alpha1", "Zeke"); _BIS_SR( GIE ); // Sooner or later, you're gonna have to Enter LPM3 w/ interrupt while(1) { // May have to add some servicing routines in here that aren't controlled by the 1 second timer // This is a place holder. // Decide on whether you're going to use an infinite loop or send the micro into LPM3 mode w/ Interrupts enabled. } } // Period of this interrupt is set in InitMSP430 #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { // Update the system tick count every interrupt TimerTick++; // Update these state machines every 1 second if( TimerTick % 2 ) { UpdateTimerStateMachine(); UpdateTrafficLightStateMachine(); } // Update the output state of each control line every 0.5 seconds UpdateIOs(); }
     
     
    And here's my InitMSP430() function:

    /******************************************************************************* * InitMSP430() * * Initializes the resources of the MSP430 for this program. * ******************************************************************************/ void InitMSP430( void ) { // Configure these I/O pins to outputs pinModeP1( onGREENLED, OUTPUT ); pinModeP1( onREDLED, OUTPUT ); pinModeP1( onYELLOWLED, OUTPUT ); // Set these Outputs to default states digitalWriteP1( onGREENLED, HIGH ); digitalWriteP1( onREDLED, HIGH ); digitalWriteP1( onYELLOWLED , HIGH ); // Configure the TimerA to run at a 1 second rate CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = TIMEBASE-1; // 0.25 second timer operation TACTL = TASSEL_1 + MC_1; // ACLK, upmode }
     
    So, these are the files that will lay the foundation for a well balanced state machine. In this example, I'm going to simulate a traffic light state machine. It seems to me that it is the example that every prof uses in control systems lab class.
     
    I haven't posted up the routines that really matter yet. Namely, the UpdateStateMachine() functions. They are the gears in this transmission.
     
    So, stay tuned for more. I hope you will like this.
  8. Like
    zeke got a reaction from gatesphere in State Machine Example Code   
    Hi Guys,
     
    I've been thinking about the topic of state machines lately and I thought I'd try to whip up a posting on my approach to state machines.
     
    I've written a state machine for my client but I can't post that without a lot of changes. So I'm going to convert it into a traffic light state machine example.
     
    Hmmm... I just realized that I should talk about what a state machine is but I haven't got anything prepared yet. So, for now, I'll assume you know what it is.
     
    Here's my definitions and declarations:
     

    #include // add header file for MSP430G2231 device. #include #define VERSION(id, rev, tag) const char id##_version[] = "@(#)Id:" #id " Ver:" rev " Released by:" tag " Built:" __DATE__ " " __TIME__ #define INPUT 0 #define OUTPUT 1 #define TRUE 1 #define FALSE 0 #define HIGH 1 #define LOW 0 #define TOGGLE 2 #define nothing1 BIT0 // P1.0, 0x01, 0b0000 0001 #define onGREENLED BIT1 // P1.1, 0x02, 0b0000 1000 #define onREDLED BIT2 // P1.2, 0x04, 0b0001 0000 #define nothing2 BIT3 // P1.3, 0x08, 0b0000 0010 #define nothing3 BIT4 // P1.4, 0x10, 0b0000 0100 #define onYELLOWLED BIT5 // P1.5, 0x20, 0b0010 0000 #define nothing4 BIT6 // P1.6, 0x40, 0b0100 0000 #define nothing5 BIT7 // P1.7, 0x80, 0b1000 0000 #define TIMEBASE 16384 // This is selected ACLK/2, Production value = 16384 #define STARTTIMEOUT 5 // 5 seconds #define OVERALLTIMEOUT 43200 // 12hr*60min*60sec = 43200 seconds /******************************************************************************* * Global Variables * ******************************************************************************/ unsigned char TimerTick;
     
     
     
    So, here's my main function and interrupt routine. This will configure the msp430 to interrupt every TIMEBASE counts. In this case, the result is an interrupt every 0.25 seconds.
     

    void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; BCSCTL3 |= XCAP_3; // Launchpad watch crystals need ~12.5 pF // Configure all IO's and their default states on the MSP430 InitMSP430(); InitIOs(); // Initialize the system tick count TimerTick = 0; // Initialize all state machines InitTimerStateMachine(); InitTrafficLightStateMachine(); VERSION(TrafficLightStateMachineExample, "Alpha1", "Zeke"); _BIS_SR( GIE ); // Sooner or later, you're gonna have to Enter LPM3 w/ interrupt while(1) { // May have to add some servicing routines in here that aren't controlled by the 1 second timer // This is a place holder. // Decide on whether you're going to use an infinite loop or send the micro into LPM3 mode w/ Interrupts enabled. } } // Period of this interrupt is set in InitMSP430 #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { // Update the system tick count every interrupt TimerTick++; // Update these state machines every 1 second if( TimerTick % 2 ) { UpdateTimerStateMachine(); UpdateTrafficLightStateMachine(); } // Update the output state of each control line every 0.5 seconds UpdateIOs(); }
     
     
    And here's my InitMSP430() function:

    /******************************************************************************* * InitMSP430() * * Initializes the resources of the MSP430 for this program. * ******************************************************************************/ void InitMSP430( void ) { // Configure these I/O pins to outputs pinModeP1( onGREENLED, OUTPUT ); pinModeP1( onREDLED, OUTPUT ); pinModeP1( onYELLOWLED, OUTPUT ); // Set these Outputs to default states digitalWriteP1( onGREENLED, HIGH ); digitalWriteP1( onREDLED, HIGH ); digitalWriteP1( onYELLOWLED , HIGH ); // Configure the TimerA to run at a 1 second rate CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = TIMEBASE-1; // 0.25 second timer operation TACTL = TASSEL_1 + MC_1; // ACLK, upmode }
     
    So, these are the files that will lay the foundation for a well balanced state machine. In this example, I'm going to simulate a traffic light state machine. It seems to me that it is the example that every prof uses in control systems lab class.
     
    I haven't posted up the routines that really matter yet. Namely, the UpdateStateMachine() functions. They are the gears in this transmission.
     
    So, stay tuned for more. I hope you will like this.
  9. Like
    zeke got a reaction from RobG in State Machine Example Code   
    Hi Guys,
     
    I've been thinking about the topic of state machines lately and I thought I'd try to whip up a posting on my approach to state machines.
     
    I've written a state machine for my client but I can't post that without a lot of changes. So I'm going to convert it into a traffic light state machine example.
     
    Hmmm... I just realized that I should talk about what a state machine is but I haven't got anything prepared yet. So, for now, I'll assume you know what it is.
     
    Here's my definitions and declarations:
     

    #include // add header file for MSP430G2231 device. #include #define VERSION(id, rev, tag) const char id##_version[] = "@(#)Id:" #id " Ver:" rev " Released by:" tag " Built:" __DATE__ " " __TIME__ #define INPUT 0 #define OUTPUT 1 #define TRUE 1 #define FALSE 0 #define HIGH 1 #define LOW 0 #define TOGGLE 2 #define nothing1 BIT0 // P1.0, 0x01, 0b0000 0001 #define onGREENLED BIT1 // P1.1, 0x02, 0b0000 1000 #define onREDLED BIT2 // P1.2, 0x04, 0b0001 0000 #define nothing2 BIT3 // P1.3, 0x08, 0b0000 0010 #define nothing3 BIT4 // P1.4, 0x10, 0b0000 0100 #define onYELLOWLED BIT5 // P1.5, 0x20, 0b0010 0000 #define nothing4 BIT6 // P1.6, 0x40, 0b0100 0000 #define nothing5 BIT7 // P1.7, 0x80, 0b1000 0000 #define TIMEBASE 16384 // This is selected ACLK/2, Production value = 16384 #define STARTTIMEOUT 5 // 5 seconds #define OVERALLTIMEOUT 43200 // 12hr*60min*60sec = 43200 seconds /******************************************************************************* * Global Variables * ******************************************************************************/ unsigned char TimerTick;
     
     
     
    So, here's my main function and interrupt routine. This will configure the msp430 to interrupt every TIMEBASE counts. In this case, the result is an interrupt every 0.25 seconds.
     

    void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; BCSCTL3 |= XCAP_3; // Launchpad watch crystals need ~12.5 pF // Configure all IO's and their default states on the MSP430 InitMSP430(); InitIOs(); // Initialize the system tick count TimerTick = 0; // Initialize all state machines InitTimerStateMachine(); InitTrafficLightStateMachine(); VERSION(TrafficLightStateMachineExample, "Alpha1", "Zeke"); _BIS_SR( GIE ); // Sooner or later, you're gonna have to Enter LPM3 w/ interrupt while(1) { // May have to add some servicing routines in here that aren't controlled by the 1 second timer // This is a place holder. // Decide on whether you're going to use an infinite loop or send the micro into LPM3 mode w/ Interrupts enabled. } } // Period of this interrupt is set in InitMSP430 #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { // Update the system tick count every interrupt TimerTick++; // Update these state machines every 1 second if( TimerTick % 2 ) { UpdateTimerStateMachine(); UpdateTrafficLightStateMachine(); } // Update the output state of each control line every 0.5 seconds UpdateIOs(); }
     
     
    And here's my InitMSP430() function:

    /******************************************************************************* * InitMSP430() * * Initializes the resources of the MSP430 for this program. * ******************************************************************************/ void InitMSP430( void ) { // Configure these I/O pins to outputs pinModeP1( onGREENLED, OUTPUT ); pinModeP1( onREDLED, OUTPUT ); pinModeP1( onYELLOWLED, OUTPUT ); // Set these Outputs to default states digitalWriteP1( onGREENLED, HIGH ); digitalWriteP1( onREDLED, HIGH ); digitalWriteP1( onYELLOWLED , HIGH ); // Configure the TimerA to run at a 1 second rate CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = TIMEBASE-1; // 0.25 second timer operation TACTL = TASSEL_1 + MC_1; // ACLK, upmode }
     
    So, these are the files that will lay the foundation for a well balanced state machine. In this example, I'm going to simulate a traffic light state machine. It seems to me that it is the example that every prof uses in control systems lab class.
     
    I haven't posted up the routines that really matter yet. Namely, the UpdateStateMachine() functions. They are the gears in this transmission.
     
    So, stay tuned for more. I hope you will like this.
  10. Like
    zeke got a reaction from lvagasi in Reading the ds18b20 temperature sensor   
    Okay, I have my code running.
     
     
    Here's main.c

    #include #include "ds18b20.h" #define UART_TXD 0x02 // TXD on P1.1 (Timer0_A.OUT0) #define UART_RXD 0x04 // RXD on P1.2 (Timer0_A.CCI1A) #define UART_TBIT_DIV_2 (16000000 / (9600 * 2)) #define UART_TBIT (16000000 / 9600) #define delayMicroseconds(n) __delay_cycles(n<<4) // The One Wire bus is connected to this pin #define WIRE_PORT 7 //Remember you need a 4.7k pullup resistor here. #define LOW 0 #define HIGH 1 #define INPUT 0 #define OUTPUT 1 #define FALSE 0 #define TRUE 1 //Zeke's mod's int OW_Reset( int Pin ); void OW_WriteByte(int Pin, char d); char OW_ReadByte(int Pin); // Routines written by Peter H Anderson // http://www.phanderson.com/arduino/ds18b20_1.html char digitalRead( char Pin ); void pinMode( int Pin, int Out ); void digitalWrite( int Pin, int Bit ); // Software UART routines void TimerA_UART_init( void ); void TimerA_UART_tx( unsigned char byte ); unsigned int txData; // UART internal variable for TX unsigned char rxBuffer; // Received UART character void main(void) { // int temp = 0; int i; int ROMCode[8]; int ScratchPad[9]; int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; P1OUT = UART_RXD; // RXD as IN P1SEL = UART_TXD + UART_RXD; // Timer function for TXD/RXD pins P1DIR = UART_TXD; TimerA_UART_init(); __enable_interrupt(); while ( 1 ) { if ( 1 == OW_Reset( WIRE_PORT ) ) { OW_WriteByte( WIRE_PORT, 0x33 ); // Read ROM Code from DS18B20 for( i=0; i<8; i++ ) { // Read the values inside of the ROMCode array in the debugger window ROMCode[i] = OW_ReadByte( WIRE_PORT ); } } if ( 1 == OW_Reset( WIRE_PORT ) ) { OW_WriteByte( WIRE_PORT, SKIPROM ); // Skip ROM Code matching OW_WriteByte( WIRE_PORT, CONVERTTEMP ); // Read ROM Code from DS18B20 OW_Reset( WIRE_PORT ); OW_WriteByte( WIRE_PORT, SKIPROM ); // Skip ROM Code matching OW_WriteByte( WIRE_PORT, READSCRATCHPAD ); // Read ScratchPad from DS18B20 for( i=0; i<9; i++ ) { // Read the values inside of the ScratchPad array in the debugger window ScratchPad[i] = OW_ReadByte( WIRE_PORT ); } } OW_Reset( WIRE_PORT ); OW_WriteByte( WIRE_PORT, SKIPROM ); // Skip ROM Code matching OW_WriteByte( WIRE_PORT, CONVERTTEMP ); // Read ROM Code from DS18B20 OW_Reset( WIRE_PORT ); OW_WriteByte( WIRE_PORT, SKIPROM ); // Skip ROM Code matching OW_WriteByte( WIRE_PORT, READSCRATCHPAD ); // Read ScratchPad from DS18B20 LowByte = OW_ReadByte( WIRE_PORT ); HighByte = OW_ReadByte( WIRE_PORT ); // Thanks again "Mr. Anderson" for this code TReading = ( HighByte << 8 ) + LowByte; SignBit = TReading & 0x8000; // test most sig bit if ( 1 == SignBit ) // negative { TReading = (TReading ^ 0xffff) + 1; // 2's comp } Tc_100 = ( 6 * TReading ) + TReading / 4; // multiply by (100 * 0.0625) or 6.25 Whole = Tc_100 / 100; // separate off the whole and fractional portions Fract = Tc_100 % 100; // ********************************************************************************************************** // ***** This won't work so I am commenting it out (zeke) ***** // ***** A serial ring buffer and interrupt servicing routines is needed to make this work ***** // ***** // ***** Read the "Whole" and "Fract" values with your debugger ***** // ********************************************************************************************************** // this will print the tempature in an int8 over serial every 1 second. // TimerA_UART_tx( Whole ); // TimerA_UART_tx( Fract ); // ********************************************************************************************************** // insert a breakpoint here and observe the variables in the debugger watch window // ********************************************************************************************************** delayMicroseconds( 1000000 ); } } int OW_Reset( int Pin ) { int presence; delayMicroseconds( 0 ); // delay for 0us digitalWrite( Pin, LOW ); pinMode( Pin, OUTPUT ); delayMicroseconds( 480 ); // delay for 480us pinMode( Pin, INPUT ); delayMicroseconds( 70 ); // delay for 70us if( 0 == digitalRead( WIRE_PORT ) ) { presence = TRUE; // Presense pulse detected } else { presence = FALSE; // ds18b20 is not there } delayMicroseconds( 410 ); // delay for 410us return ( presence ); // return the sampled presence pulse result } // Peter Anderson wrote this void OW_WriteByte( int Pin, char d ) { char n; for(n=8; n!=0; n--) { if ( (d & 0x01) == 1 ) { digitalWrite( Pin, LOW ); pinMode( Pin, OUTPUT ); delayMicroseconds( 5 ); pinMode( Pin, INPUT ); delayMicroseconds( 60 ); } else { digitalWrite( Pin, LOW ); pinMode( Pin, OUTPUT ); delayMicroseconds( 60 ); pinMode( Pin, INPUT ); } d = d >> 1; } } // Peter Anderson wrote this char OW_ReadByte( int pin ) { char d, n, b; for ( n=0; n<8; n++ ) { digitalWrite( pin, LOW ); pinMode( pin, OUTPUT); delayMicroseconds( 5 ); pinMode( pin, INPUT ); delayMicroseconds( 5 ); b = digitalRead( pin ); delayMicroseconds( 50 ); d = (d >> 1) | (b << 7); // shift d to right and insert b in most sig bit position } return(d); } //------------------------------------------------------------------------------ // Arduino like digitalRead, pinMode, and digitalWrite helper functions. //------------------------------------------------------------------------------ char digitalRead( char Pin ) { // Read P1IN and mask it with the 1wPin then shift it to the LSB position return ( (P1IN & (1 << Pin) ) >> Pin ); } void pinMode( int pin, int out ) { if( 1 == out ) { P1DIR |= (1 << pin); } else { P1DIR &= (~(1 << pin)); } } void digitalWrite(int Pin, int Bit) { if ( 1 == ( Bit ) ) { P1OUT |= ( 1 << Pin ); // if the Bit is HIGH then drive the 1wBus HIGH } else { P1OUT &= ( ~(1 << Pin) ); // if the Bit is LOW then drive the 1wBus LOW } } //------------------------------------------------------------------------------ // Function configures Timer_A for full-duplex UART operation //------------------------------------------------------------------------------ void TimerA_UART_init(void) { TACCTL0 = OUT; // Set TXD Idle as Mark = '1' TACCTL1 = SCS + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture, Int TACTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode } //------------------------------------------------------------------------------ // Outputs one byte using the Timer_A UART //------------------------------------------------------------------------------ void TimerA_UART_tx(unsigned char byte) { while (TACCTL0 & CCIE); // Ensure last char got TX'd TACCR0 = TAR; // Current state of TA counter TACCR0 += UART_TBIT; // One bit time till first bit TACCTL0 = OUTMOD0 + CCIE; // Set TXD on EQU0, Int txData = byte; // Load global variable txData |= 0x100; // Add mark stop bit to TXData txData <<= 1; // Add space start bit } //------------------------------------------------------------------------------ // Timer_A UART - Transmit Interrupt Handler //------------------------------------------------------------------------------ #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A0_ISR(void) { static unsigned char txBitCnt = 10; TACCR0 += UART_TBIT; // Add Offset to CCRx if (txBitCnt == 0) // All bits TXed? { TACCTL0 &= ~CCIE; // All bits TXed, disable interrupt txBitCnt = 10; // Re-load bit counter } else { if (txData & 0x01) { TACCTL0 &= ~OUTMOD2; // TX Mark '1' } else { TACCTL0 |= OUTMOD2; // TX Space '0' } txData >>= 1; txBitCnt--; } } //------------------------------------------------------------------------------ // Timer_A UART - Receive Interrupt Handler //------------------------------------------------------------------------------ #pragma vector = TIMERA1_VECTOR __interrupt void Timer_A1_ISR(void) { static unsigned char rxBitCnt = 8; static unsigned char rxData = 0; switch ( __even_in_range(TAIV, TAIV_TAIFG) ) // Use calculated branching { case TAIV_TACCR1: // TACCR1 CCIFG - UART RX TACCR1 += UART_TBIT; // Add Offset to CCRx if (TACCTL1 & CAP) // Capture mode = start bit edge { TACCTL1 &= ~CAP; // Switch capture to compare mode TACCR1 += UART_TBIT_DIV_2; // Point CCRx to middle of D0 } else { rxData >>= 1; if (TACCTL1 & SCCI) // Get bit waiting in receive latch { rxData |= 0x80; } rxBitCnt--; if (rxBitCnt == 0) // All bits RXed? { rxBuffer = rxData; // Store in global variable rxBitCnt = 8; // Re-load bit counter TACCTL1 |= CAP; // Switch compare to capture mode __bic_SR_register_on_exit(LPM0_bits); // Clear LPM0 bits from 0(SR) } } break; } }
     
    And here's ds18b20.h

    #ifndef DS18B20_H_ #define DS18B20_H_ // 'tick' values // Compute these from DalSemi AN126 xls worksheet //int A,B,C,D,E,F,G,H,I,J; #define tA 6 #define tB 64 #define tC 60 #define tD 10 #define tE 9 #define tF 55 #define tG 0 #define tH 480 #define tI 70 #define tJ 410 // 1-Wire ROM Command Codes #define SEARCHROM 0xF0 #define READROM 0x33 #define MATCHROM 0x55 #define SKIPROM 0xCC #define ALARMSEARCH 0xEC // DS18B20 Function Commands #define CONVERTTEMP 0x44 #define WRITESCRATCHPAD 0x4E #define READSCRATCHPAD 0xBE #define COPYSCRATCHPAD 0x48 #define RECALLEE 0xB8 #define READPOWERSUPPLY 0xB4 #endif /*DS18B20_H_*/
     
    Again, make sure you calibrate the DCO for 16MHz if you're using a value line device.
     
    Enjoy!
  11. Like
    zeke got a reaction from jsolarski in Ethernet to serial module?   
    I received my Stellaris S2E kit today. It's a neat little device.
     
    The serial interface board is kinda weird but I understand why they stacked it up that way. The USB cable is there to supply power to the target board. Sneaky.
     
    I like the little webserver on-board. It's slow but it's there so that you can configure the communication parameters.
     
    The telnet interface is cool. Telnet to x.x.x.x:23 for port1 and x.x.x.x:26 for port2. You've gotta have a terminal connected to the DB9 serial port connector to perform end to end testing.
     
    I see this as a reference design device. It should be adapted to your application - whatever that might be.
     
    I can see this being successfully adapted as an LP shield board. It would need a complete board respin and some new code created.
     
    I can also see this ref design being successfully adapted as an ethernet to Zigbee link board. Again, a new board would be created to accommodate a Digi board and the code could be modified to be able to configure the Digi module.
     
    I'm going to keep playing with this module. I may even get a second one so that I can try a long S2E2S link configuration.
     
    All in all, I think it's a 9 out of 10 on the Nerdy Cool Scale

  12. Like
    zeke reacted to oPossum in Compact async serial tx   
    Just change the serial_setup() call.
     
    For example, 57600 bps with 16 Mhz clock...
     

    serial_setup(1 << 1, 16000000 / 57600);
  13. Like
    zeke reacted to kilof in Reading the ds18b20 temperature sensor   
    Hi!
    I solved it You have right, it is easier to adopt LCD library:
     

    #define sendData(data) send(data, 1) #define sendInstruction(data) send(data, 0) #define initDisplay() sendInstruction(0x3C); sendInstruction(0x0E); clearDisplay(); sendInstruction(0x06); delayMicroseconds(2000); //for 16Mhz #define clearDisplay() sendInstruction(0x01); delayMicroseconds(2000) #define DATAPIN BIT6 #define CLOCKPIN BIT5 #define ENABLEPIN BIT4 void send(char data, char registerSelect); void sendDataArray(char data[], char length); char charIndex = 0; char bitCounter = 0; void sendDataArray(char data[], char length) { charIndex = 0; while(charIndex < length) { sendData(data[charIndex]); charIndex++; [b] delayMicroseconds(100); //for 16Mhz[/b] } } void send(char data, char registerSelect) { bitCounter = 0; while(bitCounter < 8) { (data & BIT7) ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); data <<= 1; P1OUT |= CLOCKPIN; P1OUT &= ~CLOCKPIN; bitCounter++; [b] delayMicroseconds(100); //for16Mhz[/b] } registerSelect ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); P1OUT &= ~ENABLEPIN; P1OUT |= ENABLEPIN; }
    And everything works for me Of course it is @RobG code, I wrote in only delays (Thanks for 3 wire solution )
  14. Like
    zeke reacted to gordon in MSP430 data acquisition from multiple sensors   
    Are you saying you have tried, did not succeed and gave up on Blinky, everyone's best friend?
     
    You really have to do this. Everything starts with Blinky. A simple output is Blinky. Making it blink are timers. Timers are clocks. Making Blinky glow is PWM. Add a simple button and/or a pot -- inputs, interrupts, ADC.
     
    Without a strong command of these facilities any microcontroller project (not just MSP430, these are general concepts) is a quick way down. You really have to begin at the beginning. There are no shortcuts at this stage. For me, it took the Davies book, a LaunchPad, MSPGCC4, mspdebug and about three weeks to start getting the big picture. There really is no way around this.
     
    Blinky is the alphabet and the times table of it all.
  15. Like
    zeke reacted to jsolarski in MSP430 data acquisition from multiple sensors   
    check out this article
    http://alumni.cs.ucr.edu/~amitra/sdcard ... _foust.pdf
     
    and http://en.wikipedia.org/wiki/Text_file
     
    from what i understand, a txt file is a header and an EOF marker and data in-between the markers. as long as your SD card is formatted in FAT you should be able to just write header, then the data and close it out with an EOF marker and should be able to read it. If you can write files with dd then you should be able to write them with a Uc lol
     
     
    Try formatting the SD card in fat and then try writing a zero- byte file and then go from there
  16. Like
    zeke got a reaction from bluehash in MSP430 data acquisition from multiple sensors   
    You may need to step back from the details of your project for a little bit because you sound like you're drowning in the details.
     
    Oh, and stop hyperventilating. As Douglas Adams said, Don't Panic!
     
    I think you should take a tour of the MSP430 to get a feel for how things are done with it. Normally, folks try out the blinking LED sample program.
     
    I think you should also take a look at this thread. It's a collection of notes for MSP430 Beginner's. It will point out some resources that you can use to help you get up to speed. Take special note of the Davies book. It's the best one out there.
     
    Once you sort out how to drive the MSP430 then you can begin to design your system.
     
    I'll give you my approach and you can see if it might work for you. I may have to use some analogies to paint a picture in your mind. Compare those images to your situation to see if they might work.
     
    You've been asked to create a data logger. It has multiple sensors. Each sensor has it's own particular language. In the analogy, let's call them gears in a transmission. Temperature = 1st gear, Accelerometer (X,Y,Z) = 2nd gear, Time = 3rd gear and so on.
     
    The MSP430 is the engine. It spins the transmission. So, you have to get the engine running first.
     
    First, get the MSP430 running off of the 32kHz crystal. Solder on the little crystal that comes with the Launchpad.
    Then program the MSP430 to use that crystal. Your code should use interrupts. Generate an timer interrupt once a second. This is the engine speed. You will be able to change the RPM of the engine later, as needed.
     
    Then, you have to make the transmission work. This is where you would design a routine to blink a LED, or read a push button, or read the accelerometer, or write a byte to the SD card. The key is that you would do one thing at a time.
     
    So, as a test, write a blink LED routine. Then, make it blink in time with the 1 second interrupt. If you can turn the LED off or on then do that inside the interrupt routine. Just one thing though - on or off.
     
    After that, you have to add in each routine so that it will do its operation once every revolution of the timer.
     
    What you are building here is a state machine. The 1 second timer is the driving force of the state machine. The sub-routines are the individual states. You transition from state to state using time or input signals as triggers.
     
     
    Are you starting to see the big picture yet?
     
    Summary:
    Design your project as a state machine.
    Use the timer to run the state machine.
    Switch states using time intervals or input signals.
    Design each state to be a single operation that can complete in a short amount of time.
    Start small and simple.
    Design on paper first. I can't stress this enough. Know what you're doing before you begin coding.
     
    And, ask questions. There's a lot of smart and experienced people lurking here!
  17. Like
    zeke got a reaction from gordon in MSP430 data acquisition from multiple sensors   
    You may need to step back from the details of your project for a little bit because you sound like you're drowning in the details.
     
    Oh, and stop hyperventilating. As Douglas Adams said, Don't Panic!
     
    I think you should take a tour of the MSP430 to get a feel for how things are done with it. Normally, folks try out the blinking LED sample program.
     
    I think you should also take a look at this thread. It's a collection of notes for MSP430 Beginner's. It will point out some resources that you can use to help you get up to speed. Take special note of the Davies book. It's the best one out there.
     
    Once you sort out how to drive the MSP430 then you can begin to design your system.
     
    I'll give you my approach and you can see if it might work for you. I may have to use some analogies to paint a picture in your mind. Compare those images to your situation to see if they might work.
     
    You've been asked to create a data logger. It has multiple sensors. Each sensor has it's own particular language. In the analogy, let's call them gears in a transmission. Temperature = 1st gear, Accelerometer (X,Y,Z) = 2nd gear, Time = 3rd gear and so on.
     
    The MSP430 is the engine. It spins the transmission. So, you have to get the engine running first.
     
    First, get the MSP430 running off of the 32kHz crystal. Solder on the little crystal that comes with the Launchpad.
    Then program the MSP430 to use that crystal. Your code should use interrupts. Generate an timer interrupt once a second. This is the engine speed. You will be able to change the RPM of the engine later, as needed.
     
    Then, you have to make the transmission work. This is where you would design a routine to blink a LED, or read a push button, or read the accelerometer, or write a byte to the SD card. The key is that you would do one thing at a time.
     
    So, as a test, write a blink LED routine. Then, make it blink in time with the 1 second interrupt. If you can turn the LED off or on then do that inside the interrupt routine. Just one thing though - on or off.
     
    After that, you have to add in each routine so that it will do its operation once every revolution of the timer.
     
    What you are building here is a state machine. The 1 second timer is the driving force of the state machine. The sub-routines are the individual states. You transition from state to state using time or input signals as triggers.
     
     
    Are you starting to see the big picture yet?
     
    Summary:
    Design your project as a state machine.
    Use the timer to run the state machine.
    Switch states using time intervals or input signals.
    Design each state to be a single operation that can complete in a short amount of time.
    Start small and simple.
    Design on paper first. I can't stress this enough. Know what you're doing before you begin coding.
     
    And, ask questions. There's a lot of smart and experienced people lurking here!
  18. Like
    zeke got a reaction from RobG in MSP430 data acquisition from multiple sensors   
    You may need to step back from the details of your project for a little bit because you sound like you're drowning in the details.
     
    Oh, and stop hyperventilating. As Douglas Adams said, Don't Panic!
     
    I think you should take a tour of the MSP430 to get a feel for how things are done with it. Normally, folks try out the blinking LED sample program.
     
    I think you should also take a look at this thread. It's a collection of notes for MSP430 Beginner's. It will point out some resources that you can use to help you get up to speed. Take special note of the Davies book. It's the best one out there.
     
    Once you sort out how to drive the MSP430 then you can begin to design your system.
     
    I'll give you my approach and you can see if it might work for you. I may have to use some analogies to paint a picture in your mind. Compare those images to your situation to see if they might work.
     
    You've been asked to create a data logger. It has multiple sensors. Each sensor has it's own particular language. In the analogy, let's call them gears in a transmission. Temperature = 1st gear, Accelerometer (X,Y,Z) = 2nd gear, Time = 3rd gear and so on.
     
    The MSP430 is the engine. It spins the transmission. So, you have to get the engine running first.
     
    First, get the MSP430 running off of the 32kHz crystal. Solder on the little crystal that comes with the Launchpad.
    Then program the MSP430 to use that crystal. Your code should use interrupts. Generate an timer interrupt once a second. This is the engine speed. You will be able to change the RPM of the engine later, as needed.
     
    Then, you have to make the transmission work. This is where you would design a routine to blink a LED, or read a push button, or read the accelerometer, or write a byte to the SD card. The key is that you would do one thing at a time.
     
    So, as a test, write a blink LED routine. Then, make it blink in time with the 1 second interrupt. If you can turn the LED off or on then do that inside the interrupt routine. Just one thing though - on or off.
     
    After that, you have to add in each routine so that it will do its operation once every revolution of the timer.
     
    What you are building here is a state machine. The 1 second timer is the driving force of the state machine. The sub-routines are the individual states. You transition from state to state using time or input signals as triggers.
     
     
    Are you starting to see the big picture yet?
     
    Summary:
    Design your project as a state machine.
    Use the timer to run the state machine.
    Switch states using time intervals or input signals.
    Design each state to be a single operation that can complete in a short amount of time.
    Start small and simple.
    Design on paper first. I can't stress this enough. Know what you're doing before you begin coding.
     
    And, ask questions. There's a lot of smart and experienced people lurking here!
  19. Like
    zeke got a reaction from jsolarski in Power supply testing procedures?   
    Well, it looks like I'm gonna answer my own question.
     
    I found this document that describes the salient details of power supply testing.
  20. Like
    zeke reacted to GeekDoc in The Party Thread!   
    I hate to be the downer of the party, but I would like to ask all our US members to take a short time Monday (Memorial Day) to truly remember and understand what all of the fallen military members have really meant to this country's history, and to how you live your life today.
     
    (end of old vet's speech :| )
  21. Like
    zeke got a reaction from bluehash in Datalogger?   
    You've got me thinking about an interesting idea.
     
    I stumbled across Adobe Flex and it got me thinking that I could use it for a cross platform runtime.
     
    I don't know if it can obtain access to the USB/Serial ports. I'll have to check that out.
     
    Here's a demo program called TourdeFlex that shows off a lot of what it can do.
     
    Apparently, you can get AIR to talk to a serial port but you have to use a proxy program since AIR talks TCP ports only. Check out this article for more info.
  22. Like
    zeke reacted to bluehash in Datalogger?   
    Well, on the other hand, Labview costs thousands. But you can distribute the runtime to your clients for free.
  23. Like
    zeke got a reaction from Fe2o3Fish in The Party Thread!   
    It's called Memorial Day for a reason. No need to think you're a downer.
     
    I'm Canadian and I'll stand with Y'All and remember too!
  24. Like
    zeke got a reaction from EngIP in Are the ValueLine chip outputs current limited?   
    Yeah, I smoked a port pin on a g2231 recently when I tried to make it pull down a 5V line - active low style.
     
    It wasn't happy. It got real hot. I had to replace it then redesign the circuit.
     
    If you try to pull a pin above 4.3V then the protection diode will get damaged. That's 3.6V + 0.7V for reference.
  25. Like
    zeke got a reaction from RobG in Are the ValueLine chip outputs current limited?   
    Yeah, I smoked a port pin on a g2231 recently when I tried to make it pull down a 5V line - active low style.
     
    It wasn't happy. It got real hot. I had to replace it then redesign the circuit.
     
    If you try to pull a pin above 4.3V then the protection diode will get damaged. That's 3.6V + 0.7V for reference.
×
×
  • Create New...