MWX Library
latest_en
latest_en
  • The MWX Library
  • revision history
  • About the MWX library
    • License
    • Terms
    • The design policy
  • Install and Build
    • Environment (OS, etc.)
    • Installing the TWELITE SDK
    • Building ACT
    • Creating a new project
    • Installing VSCode
    • Build definition Makefile
    • Other platforms
  • Sample ACTs
    • act0 .. 4
    • Scratch
    • Slp_Wk_and_Tx
    • Parent_MONOSTICK
    • PingPong
    • BRD_APPTWELITE
    • BRD_I2C_TEMPHUMID
    • PAL_AMB
    • PAL_AMB-usenap
    • PAL_AMB-bhv
    • PAL_MAG
    • PAL_MOT-single
    • PAL_MOT-fifo
    • PulseCounter
    • WirelessUART
    • Rcv_Univsl
    • Unit_???
  • API
    • Definition.
    • class object
      • the_twelite
      • Analogue
      • Buttons
      • EEPROM
      • PulseCounter
      • Serial
      • SerialParser
      • SPI
        • SPI (using member functions)
        • SPI (using helper class)
      • TickTimer
      • Timer0 .. 4
      • Wire
        • Wire (using member functions))
        • Wire (using helper class)
    • Classes
      • MWX_APIRET
      • alloc
      • axis_xyzt
      • packet_rx
      • packet_tx
      • serparser
      • pktparser
        • E_PKT
        • idenify_packet_type()
        • TwePacket
          • TwePacketTwelite
          • TwePacketIO
          • TwePacketUART
          • TwePacketPAL
      • smplbuf
        • .get_stream_helper()
        • smplbuf_strm_u8
      • smplque
      • mwx::stream
        • format (mwx::mwx_format)
        • mwx::bigendian
        • mwx::crlf
        • mwx::flush
        • stream_helper
      • SM_SIMPLE state machine
    • Call back functions
      • setup()
      • begin()
      • loop()
      • wakeup()
      • init_coldboot()
      • init_warmboot()
      • on_rx_packet()
      • on_tx_comp()
    • BEHAVIOR
      • PAL_AMB-behavior
    • Functions
      • System Functions
        • millis()
        • delay()
        • delayMicroseconds()
        • random()
      • DIO General purpose IO
        • pinMode()
        • digitalWrite()
        • digitalRead()
        • attachIntDio()
        • detachIntDio()
        • digitalReadBitmap()
      • Utility Functions
        • Printf utils
        • pack_bits()
        • collect_bits()
        • Byte array utils
        • pack_bytes()
        • expand_bytes()
        • CRC8, XOR, LRC
        • div100()
        • Scale utils
        • pnew
    • External Libraries
      • EASTL
  • Board (BRD)
    • <BRD_APPTWELITE>
    • <MONOSTICK>
    • PAL
      • <PAL_AMB>
      • <PAL_MAG>
      • <PAL_MOT>
      • <PAL_NOTICE>
    • <CUE>
  • Sensor Devices (SNS)
    • SHTC3 - Temp/Humd sensor
    • SHT3x - Temp/Humd sensor
    • LTR-308ALS - Luminance Sensor
    • MC3630 - Accel sensor
    • BMx280 - Temp/Humd/Pressure Sensor
    • PCA9632 - LED Driver
  • Network (NWK)
    • Simple Relay Net <NWK_SIMPLE>
    • Layered Tree Net <NWK_LAYERED>
  • Settings (STG) - Interactive settings mode
    • <STG_STD>
GitBook提供
このページ内
  • Function of ACT
  • How to use ACT
  • Required TWELITE
  • Explanation of ACT
  • setup()
  • begin()
  • wakeup()
  • loop()
PDFとしてエクスポート
  1. Sample ACTs

PulseCounter

前へPAL_MOT-fifo次へWirelessUART

最終更新 2 年前

is an example of an ACT.

The pulse counter counts the number of rising or falling pulses of a signal without intervening microcontroller. It can be used to count irregular pulses and send wireless packets when the count reaches a certain number of times.

Function of ACT

  • Counts the pulses connected to DIO8 on the Child Node side and transmits them wirelessly after a certain period of time or when a certain number of counts are detected.

  • The Child Node side operates while sleeping.

How to use ACT

Required TWELITE

Role
Example

Parent Node

Child Node

Explanation of ACT

setup()

// Pulse Counter setup
PulseCounter.setup();

Initializes the pulse counter.

begin()

void begin() {
	// start the pulse counter capturing
	PulseCounter.begin(
		  100 // 100 count to wakeup
		, PIN_INT_MODE::FALLING // falling edge
		);

	sleepNow();
}

Starts the pulse counter operation and performs the first sleep. The first parameter of PulseCounter.begin() is the count number 100 to generate a wake-up interrupt, and the second is the falling detection PIN_INT_MODE::FALLING.

wakeup()

void wakeup() {
	Serial	<< mwx::crlf
			<< "--- Pulse Counter:" << FOURCHARS << " wake up ---"
			<< mwx::crlf;

	if (!PulseCounter.available()) {
		Serial << "..pulse counter does not reach the reference value." << mwx::crlf;
		sleepNow();
	}
}

Checks PulseCounter.available() when waking up. available, that is, true, indicates that the count is greater than or equal to the specified count. If it is false, it resleeps.

If the count is more than the specified number, loop() processes the transmission and waits for the completion of the transmission.

loop()

uint16_t u16ct = PulseCounter.read();

Reads the pulse count value. The counter is reset after the readout.

ACT in action.。

1. 2. +

pulse counter
MONOSTICK BLUE or RED
Parent_MONOSTICK
TWELITE DIP
BLUE PAL or RED PAL
environmental sensor pal AMBIENT SENSE PAL