Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: Is anyone actually using the QP event-drive framework? on: October 06, 2012, 04:29:37 pm
The QP examples seemed overly complex, so I made a try at coding a simple blink sketch last night, but so far I've had no luck at runtime.  It compiles, but it doesn't even output the serial stuff during setup (BSP_init does that).  The led doesn't blink.

It is a lot of code to set up resources and manage the control flow.  I'm also learning the Arduino IDE, so I'm not even sure which files it's linking to, but I copied a couple to this sketch from the Dining Philosophers QP example. 

In any case this attempt just has two states, on and off, and sets up timer events to trigger the transitions.  I did learn a bit about how periodic events are set up, and how the class is written to accept events and do state transitions, but it looks like I'm still in the dark about getting it initialized.

#include <qp_port.h>
#include "bsp.h"
#include <qf.h>

enum DPPSignals {

#define BLINK_PERIOD 100
#define ON_TIME 50

class Blinker :
public QP::QActive {
  uint8_t  led_num;                             // led to blink
  QP::QTimeEvt off_timeEvt;
  QP::QTimeEvt on_timeEvt;

    led_num(13) // constant for now

  static QP::QState initial (Blinker *me, QP::QEvent const *e) {
    me->subscribe(ON_SIG);                          // subscribe to HUNGRY
    me->subscribe(OFF_SIG);                              // subscribe to DONE
    me->off_timeEvt.postEvery( me, BLINK_PERIOD );
    me->on_timeEvt.postEvery( me, BLINK_PERIOD );
    me->off_timeEvt.rearm( ON_TIME ); // rephase by ON_TIME
    return Q_TRAN(&Blinker::off);

  static QP::QState on (Blinker *me, QP::QEvent const *e) {
    switch (e->sig) {
    case OFF_SIG:
      return Q_TRAN( &Blinker::off );     
        digitalWrite( 13, HIGH );
        return Q_HANDLED();
  static QP::QState off (Blinker *me, QP::QEvent const *e) {
    switch (e->sig) {
    case ON_SIG:
      return Q_TRAN( &Blinker::on );     
        digitalWrite( 13, LOW );
        return Q_HANDLED();

static QP::QEvent const *l_blinkQueueSto[5]; // queue for blinker
static QP::QSubscrList   l_subscrSto[10];
static QF_MPOOL_EL(QP::QEvt) l_smlPoolSto[5];//storage for small epool

// the one true blinker
static Blinker l_Blinker;
QP::QActive * const AO_Blinker = &l_Blinker;

void setup() {
  pinMode(13, OUTPUT);

  QP::QF::init();       // initialize the framework and the underlying RT kernel

  BSP_init();                                          // initialize the BSP

  // initialize event pools...
  QP::QF::poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

  QP::QF::psInit(l_subscrSto, Q_DIM(l_subscrSto));     // init publish-subscribe

  // start the active objects...

  l_blinkQueueSto, Q_DIM(l_blinkQueueSto),
  (void *)0, 0U);

2  Using Arduino / General Electronics / Re: Running high power led's without drivers. on: October 05, 2012, 08:10:34 pm
Direct-drive works, but it's the most annoying way to drive an LED.  The light output starts out very high, then declines rapidly (exponentially), but full depletion takes a long time and isn't necessarily matched to the minimum voltage that the battery can tolerate. 
3  Using Arduino / Project Guidance / Re: Is anyone actually using the QP event-drive framework? on: October 02, 2012, 01:46:53 pm
I ran across this the other day too, and found this thread while looking for opinions on it.  It seems to fit my idea of how to program a microcontroller, probably because I did some real-time programming a long time ago.  Compared to the stuff I used to do this seems luxurious -- a pub/sub interrupt handler, event queuing, a choice of pre-emptive or not, etc.

One of the docs says it takes 1-2k of flash, so it's apparently not too heavy.

If I have time I'll try it out and post my findings.
4  Using Arduino / Sensors / Re: [UPDATED] motion detector that works behind clear glass window? on: September 27, 2012, 05:38:16 pm
I think ordinary white reflectors will work.  They're made to reflect back in the source direction.
Pages: [1]