This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F28069M: LAUNCHXL-F28069M

Part Number: LAUNCHXL-F28069M

Hello! I'm just wondering if the sampling input is configurable for a single pin, or if we HAVE to use 8 pins (GPIO7-GPIO15) to use that function? I'd like to use it to read an ultrasonic sensor input which reads a digital input over an amount of time, and takes action based on what the sampling period determines. I am using multiple ultrasonic sensors but the data they collect is for different functions. I might be misunderstanding the reference guide, but I'd like to sample a single ultrasonic sensor with one pin over the period. Is that doable?

  • Andrew,

    I'm not following your question. Can you point to the specific section in the reference guide that you are referring to? It would also help if you can describe the signal that you are trying to sense.

    -Tommy
  • Hello!

    Im referring to 1.5.4 on page 123 in the subheading 1.5.4.3 'Qualification using a sampling window', where it says 'The sampling period is configurable in groups of 8 input signals'.

    I'd like to use like this:
    An ultrasonic sensor returns a high digital signal for a length of time based on how close it is to the object that is detected, ie. If its far away, the digital signal is high for say 100micro-seconds, if the object is close to the ultrasonic sensor, then the ultrasonic sensor will output a high digital spike for a very short period of time (say 1micro-second).
    Ideally, Id like to detect the positive edge of the signal returned from the ulatrsonic sensor, and sample it over an amount of time. If it goes low really quickly, I know the theres an object close to the ultrasonic sensor. If it stays high, I know the object is far away.

    The way I interpret the reference guide, is that the sampling function needs 8-inputs. Is this right?

    Our robot has 5 ultrasonic sensors, and we just need 1 input pin for each sensor. Would you have any suggestions?
  • Andrew,

    For clarity, that is a GPIO feature to help reject signal bounce/noise. The way to interpret that sentence is that you may configure the qualification window that is applied to the GPIO signals. However, each group of eight GPIO signals will share the same qualification window setting (because it would require an impractical number of register fields to allow per-pin configuration). The eight GPIO signals will otherwise operate independently of each other.

    If you are interested in measuring pulse duration or duty cycle, I recommend that you look into the eCAP module. It was designed for that purpose.

    -Tommy

  • Hey Tommy, I'm just wondering which example project would work best for my application. 'ecap_apwn' or 'ecap_capture_apwn'?
  • It would be ecap_capture_pwm.
  • Hey Tommy!

    I hate to bug you more, but i'm having trouble understanding just exactly how this works. This is is my 2nd microcontroller as im just as 2nd year student, but I have some questions regarding this, and I hope you can help me! If not, just let me know and I'll post a new thread!

    We're trying to set it up like this:

    We just want to measure t_pw.

    We've set up ECCTL1 as so:

    ECap1Regs.ECCTL1.bit.FREE_SOFT = 1;          //stop after interrupt for debugging purposes

    ECap1Regs.ECCTL1.bit.PRESCALE = 0;  // no diviser

    ECap1Regs.ECCTL1.bit.CAPLDN = 1 // enable capture units

    ECap1Regs.ECCTL1.bit.CAP1POL = 1; // start timing on Falling edge
    ECap1Regs.ECCTL1.bit.CAP2POL = 0; // return value on Rising edge
    ECap1Regs.ECCTL1.bit.CAP3POL = 1; // start timing on Falling edge
    ECap1Regs.ECCTL1.bit.CAP4POL = 0; // start timing on Rising edge

    ECap1Regs.ECCTL1.bit.CTRRST1 = 1; //  after detecting a rising edge, reset the timer
    ECap1Regs.ECCTL1.bit.CTRRST2 = 1; //  after detecting a falling edge, return the value
    ECap1Regs.ECCTL1.bit.CTRRST3 = 1; //  this just shadows eCAP1, so shouldnt it reset when we reset CTRRST1?
    ECap1Regs.ECCTL1.bit.CTRRST4 = 1; //  this just shadows eCAP2, so shouldnt it reset when we reset CTRRST2?

    // CONTROL REGISTER 2

    ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous because we want to keep the timer running after the first edge (event)?

    ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // iwe just want the difference between the rising event and falling event so this doesn't matter?

    ECap1Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
    ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through

    ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
    ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot

    ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

    ECap1Regs.ECEINT.bit.CEVT4 = 1;            // 2 events (rising then falling) = interrupt, then we get the value

    ______________________

    Does this make sense?

  • Andrew,

    Next time, it would probably be best to start a new post, but no problem.

    In plain English what are you trying to do with the eCAP? Something like: I am trying to capture the on-time of every pulse. OR, I am trying to measure the duty cycle of the first pulse after an event "X".

    Reading through your comments it seems like you are a little confused on the function of the eCAP. Lets talk about a few of them.

    Andrew Wenaus said:
    ECap1Regs.ECCTL1.bit.CAP1POL = 1; // start timing on Falling edge
    ECap1Regs.ECCTL1.bit.CAP2POL = 0; // return value on Rising edge
    ECap1Regs.ECCTL1.bit.CAP3POL = 1; // start timing on Falling edge
    ECap1Regs.ECCTL1.bit.CAP4POL = 0; // start timing on Rising edge

    The polarity bit simply sets what event will trigger CAPx to capture the timestamp counter(TSCTR). It wont have any effect on " start timing" or "return value".

    Andrew Wenaus said:
    ECap1Regs.ECCTL1.bit.CTRRST3 = 1; //  this just shadows eCAP1, so shouldnt it reset when we reset CTRRST1?
    ECap1Regs.ECCTL1.bit.CTRRST4 = 1; //  this just shadows eCAP2, so shouldnt it reset when we reset CTRRST2?

    These do not shadow CAP1 or CAP2. That functionality is only used when the eCAP is in APWM mode. This comment also makes it sound as if you are thinking of each of the CAPx registers as it's own timer. That is not the case, there is one time for the entire module and the CAPx registers simply store the value of the TSCTR when their even occurs.

    Andrew Wenaus said:
    ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous because we want to keep the timer running after the first edge (event)?

    You have 2 options 1. One-shot mode: the eCAP module will stop after the modulo counter reaches the value in STOP_WRAP. In continuous mode the eCAP module will continue to operate after the modulo counter reaches the STOP_WRAP value, "wrapping" back to CAP1 and beginning to overwrite values.

    Andrew Wenaus said:
    ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // iwe just want the difference between the rising event and falling event so this doesn't matter?

    This determines if the eCAP will stop and wait an indefinite amount of time for you to read out the values or if it will overwrite the CAPx registers if new rising/falling edges are detected.

    I would recommend starting with an example and then reading the chapter so that you can understand what each line of code is doing. Luckily the eCAP is a very simple module and the chapter is verbose enough to explain of the finer details.

    Regards,
    Cody

  • Hey Cody!

    This has been a huge help! Essentially, we want to capture the width of a pulse produced by a sensor.

    We've decided on a system which will rotate through the 5 ultrasonic sensors and ideally, we'd like to use the difference function to determine the time between the first event and second event and then reset.

    We just have one more question! How do we 'reset' the event detection after we detect the 2nd event? I'll try to elaborate here.. We want to:
    1. Detect Cap1
    2. Detect Cap2
    3. Return the difference (also, which register is the difference stored in?)
    4. Use the difference to evalaute stuff
    5. Select the next sensor (which we can handle)
    6. Repeat

    Our problem right now, is the fact that we have Cap 3 and Cap4 that we'd like to ignore if we can!

    Thats our issue right now! I really do appreciate your help! We are definitely stressed about getting our capstone project done in time, and you, and youre co-workers are really helping us out quite a bit, which is awesome!

    Thanks!


    Andrew
  • Andrew,

    The first thing you need to do is choose Continuous mode or One-shot mode.

    Andrew Wenaus said:
    How do we 'reset' the event detection after we detect the 2nd event?

    You can disable CAP3 and CAP4 if you modify the STOP_WRAP value.

    Andrew Wenaus said:
    which register is the difference stored in?

    The eCAP doesn't automatically return the difference. When read, it returns the value of the TSCTR at the time of the event. If you want to save time and avoid preforming "CAP2-CAP1" in your code: You could setup the eCAP to clear TSCTR at CAP1's event and then the stored value in CAP2 would be the difference between these events.

    I know the eCAP looks daunting, but it's actually a simple module!! I would estimate that you could understand 95% of the eCAP's functions with ~4 hours of working with examples and reading the manual... Which may be faster than asking questions on the forum.

    Look into the registers I mentioned above and if you have more questions keep them coming!

    Regards,
    Cody