Skip to content

Commit

Permalink
Merge branch 'docusaurus-version' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
limengdu authored Nov 14, 2024
2 parents 3bf78a9 + f9bde0b commit 8a59874
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ sidebar_position: 0
</tr>
<tr>
<th>Low Power Consumption Model</th>
<td>Normal: <strong>3.7V/6.71 mA</strong> <br></br> Sleep Model: <strong>3.7V/1.91mA</strong> <br></br> Deep Sleep Model: <strong>3.7V/4.66μA</strong></td>
<td>Normal: <strong>3.7V/6.71 mA</strong> <br></br> Sleep Model: <strong>3.7V/1.91mA</strong> <br></br> Deep Sleep Model: <strong>3.7V/4.66μA</strong></td>
<td>Normal: <strong>3.7V/6.71 mA</strong> <br></br> Sleep Model: <strong>3.7V/1.91mA</strong> <br></br> Deep Sleep Model: <strong>3.7V/1.95μA</strong></td>
<td>Normal: <strong>3.7V/6.71 mA</strong> <br></br> Sleep Model: <strong>3.7V/1.91mA</strong> <br></br> Deep Sleep Model: <strong>3.7V/1.95μA</strong></td>
</tr>
<tr>
<th>Working Temperature</th>
Expand Down Expand Up @@ -489,6 +489,9 @@ void loop()
}

```
<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/XIAO_MG24/Getting_Start/100.png" style={{width:1000, height:'auto'}}/></div>
## Resources
### For Seeed Studio XIAO MG24 Sense
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
---
description: Build a simplp Clock with Seeed Studio XIAO RA4M1.
title: XIAO RA4M1 Demo for Clock
keywords:
- ra4m1
- xiao
- clokc
image: https://files.seeedstudio.com/wiki/RA4M1_Application/top.png
side_position: 2
slug: /xiao_ra4m1_clock
last_update:
date: 11/12/2024
author: Jason
---


<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/RA4M1_Application/top2.png" style={{width:600, height:'auto'}}/></div>


## Inspiration arises

This project gained significant popularity on YouTube some time ago. It featured a compact box that housed a development board, a motor, and a motor driver board—an impressive feat of space management. Coincidentally, our XIAO series boasts a very small form factor. Imagine the possibilities if we combined the smallest development board with the smallest motor driver board! Join me on this exciting journey of Clock Demos 😀!

## Hadware Overview

### MCU

<div class="table-center">
<table align="center">
<tr>
<th>Seeed Studio XIAO MG24</th>
</tr>
<tr>
<td><div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/XIAO-R4AM1/img/2-102010551-Seeed-Studio-XIAO-RA4M1-45font.jpg" style={{width:300, height:'auto'}}/></div></td>
</tr>
<tr>
<td><div class="get_one_now_container" style={{textAlign: 'center'}}>
<a class="get_one_now_item" href="https://www.seeedstudio.com/Seeed-XIAO-RA4M1-p-5943.html">
<strong><span><font color={'FFFFFF'} size={"4"}> Get One Now 🖱️</font></span></strong>
</a>
</div></td>
</tr>
</table>
</div>


### Circuit Board

With the same volume as XIAO, simply weld the mother seat and insert XIAO and the motor into it to operate.

<div style={{textAlign:'center'}}><img src="https://files.seeedstudio.com/wiki/RA4M1_Application/2.png" style={{width:500, height:'auto'}}/></div>

:::tip
Both motors and components need to be purchased by oneself.
:::

### Software Overview
```c

// This code controls a stepper motor for a clock project,
// allowing the minute hand to rotate accurately based on time.

// Please tune the following value if the clock gains or loses time.
// Theoretically, the standard value is 60000 milliseconds per minute.
#define MILLIS_PER_MIN 60000 // milliseconds per a minute

// Motor and clock parameters
// Total steps for a full turn of the minute rotor
// Calculated as 4096 steps per revolution * 90 degrees / 12 hours
#define STEPS_PER_ROTATION 30720 // steps for a full turn of minute rotor

// Wait time for a single step of the stepper motor
int delaytime = 2;

// Ports used to control the stepper motor
// If your motor rotates in the opposite direction,
// change the order of the port numbers as needed.
int port[4] = {0, 1, 2, 3};

// Sequence of stepper motor control
// This array defines the control sequence for the motor phases.
int seq[8][4] = {
{ LOW, HIGH, HIGH, LOW},
{ LOW, LOW, HIGH, LOW},
{ LOW, LOW, HIGH, HIGH},
{ LOW, LOW, LOW, HIGH},
{ HIGH, LOW, LOW, HIGH},
{ HIGH, LOW, LOW, LOW},
{ HIGH, HIGH, LOW, LOW},
{ LOW, HIGH, LOW, LOW}
};

// Function to rotate the stepper motor based on the specified number of steps
void rotate(int step) {
static int phase = 0;
int i, j;
int delta = (step > 0) ? 1 : 7; // Determine direction of rotation
int dt = 20; // Initial delay time

step = (step > 0) ? step : -step; // Convert to positive step count
for(j = 0; j < step; j++) {
phase = (phase + delta) % 8; // Update phase
for(i = 0; i < 4; i++) {
digitalWrite(port[i], seq[phase][i]); // Control the motor
}
delay(dt); // Wait for the specified delay
if(dt > delaytime) dt--; // Gradually decrease delay
}
// Power cut: stop the motor
for(i = 0; i < 4; i++) {
digitalWrite(port[i], LOW);
}
}

// Setup function, runs once at startup
void setup() {
// Initialize motor control ports as outputs
pinMode(port[0], OUTPUT);
pinMode(port[1], OUTPUT);
pinMode(port[2], OUTPUT);
pinMode(port[3], OUTPUT);

// Perform initial approach runs to position the minute hand
rotate(-20); // Approach run in one direction
rotate(20); // Approach run in the opposite direction
rotate(STEPS_PER_ROTATION / 60); // Position the minute hand
}

// Main loop, runs continuously
void loop() {
static long prev_min = 0, prev_pos = 0; // Track previous minute and position
long min;
static long pos;

min = millis() / MILLIS_PER_MIN; // Get the current minute
if(prev_min == min) {
return; // Exit if the minute hasn't changed
}
prev_min = min; // Update previous minute
pos = (STEPS_PER_ROTATION * min) / 60; // Calculate target position
rotate(-20); // Approach run in one direction
rotate(20); // Approach run in the opposite direction
if(pos - prev_pos > 0) {
rotate(pos - prev_pos); // Rotate to the new position if needed
}
prev_pos = pos; // Update previous position
}

```
- **Ensure Stepper Motor Connections**:
Connect the four control wires of the stepper motor to the ports specified in the port array (0, 1, 2, 3).
- **Adjust Time Settings**:
Adjust the MILLIS_PER_MIN value according to actual conditions to ensure the clock is accurate. If the clock is running fast or slow, adjust this value accordingly.
- **Confirm Step Calculation**:
Ensure the STEPS_PER_ROTATION value is correctly calculated based on the actual step count of your motor and the system design.
- **Adjust Delay Time**:
The delaytime controls the delay between each step. Fine-tune this parameter based on motor performance and requirements to optimize motor operation.
- **Control Sequence Settings**:
The seq array defines the control sequence for the stepper motor. If the motor rotates in the wrong direction, you can adjust the values in this array.
- **Function Descriptions**:
rotate(int step): Controls the motor to rotate a specified number of steps. You can pass positive or negative values to control the direction. The motor will gradually decrease the delay after each rotation to increase speed.
- **setup():** Runs once at startup to initialize the control ports and perform initial positioning. This is a necessary step for setting up the motor.
- **loop():** The main loop that runs continuously to calculate the current minute and update the position of the minute hand. This function will call the rotate() function to rotate the hand at each minute update.
:::tip
- Ensure the power supply is suitable for your stepper motor and check that all connections are correct.
- During testing, monitor the operation of the motor to ensure it functions as expected and make adjustments as needed.
:::
## Demos video
<div class="table-center">
<iframe width="800" height="500" src="https://files.seeedstudio.com/wiki/RA4M1_Application/1.mp4" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
</div>
If you have more ideas and modifications, feel free to showcase them using the XIAO series!
## Resouce
- 📄 **[SCH]** [Circuit Board](https://files.seeedstudio.com/wiki/RA4M1_Application/2.zip)
- 📄 **[PCB]** [Circuit Board](https://files.seeedstudio.com/wiki/RA4M1_Application/xiao.pcb)
- 📄 **[3D]** [Clock 3D Modeling](https://files.seeedstudio.com/wiki/RA4M1_Application/clock.zip)
## Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.
<div class="button_tech_support_container">
<a href="https://forum.seeedstudio.com/" class="button_forum"></a>
<a href="https://www.seeedstudio.com/contacts" class="button_email"></a>
</div>
<div class="button_tech_support_container">
<a href="https://discord.gg/eWkprNDMU7" class="button_discord"></a>
<a href="https://github.com/Seeed-Studio/wiki-documents/discussions/69" class="button_discussion"></a>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 1 # float position is supported
position: 2 # float position is supported
label: 'Application'
collapsible: true # make the category collapsible
collapsed: true # keep the category open by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- xiao
- pin multiple
image: https://files.seeedstudio.com/wiki/XIAO-R4AM1/img/1-102010551-Seeed-Studio-XIAO-RA4M1.jpg
side_position: 1
sidebar_position: 1
slug: /xiao_ra4m1_pin_multiplexing
last_update:
date: 08/15/2024
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 2 # float position is supported
position: 1 # float position is supported
label: 'XIAO RA4M1'
collapsible: true # make the category collapsible
collapsed: true # keep the category open by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,83 @@ Before connecting to Helium, you need to configure the basic parameters of your

<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/SenseCAP/Tracker/heliumdevice.png" alt="pir" width={300} height="auto" /></p>

## ChirpStack LNS

## Helium Configuration
To receive the data from a device on the Helium network it must be associated with an LNS (LoraWAN Network Server).
New users typically use one of the [public LNSs](https://docs.helium.com/iot/find-a-lns-provider/), many of which use
ChirpStack, but it is also possible to connect one's own LNS to Helium.
The following steps are taken from the on-boarding of a T1000 to the MeteoScientific public LNS but should be easy to adapt
to other LNSs on Helium.

For those familiar with the general process the TL;DR; is:
- create an device profile with the appropriate region and the codec (see source below)
- create device with devEUI, appKey, and a `app_eui` variable with the AppEUI, all three values coming from the Sense Craft app

### Add device profile

The first step is to add a device profile for the T1000 to your ChirpStack LNS.
This tells the LNS how to decode the packets it receives from a T1000 as well as a number of other settings.

In the ChirpStack dashboard select the device profiles (green circle in the image below) and then add a device profile
(red circle).

![image](https://github.com/user-attachments/assets/7e6984e2-178b-446e-afda-29dd033c662f)

On the general tab, enter a device profile name you will recognize and select the appropriate region parameters.
The LoRaWAN MAC version should be 1.0.4.
The expected uplink interval can be set too, the main thing it controls is when the LNS user interface shows the device
as active vs. inactive. It has no effect on the delivery of packets through the LNS.

![image](https://github.com/user-attachments/assets/bb83141f-a447-437b-a29d-27e16a20ce7a)

On the Codec tab select "JavaScript functions" and enter the codec from the
[Seeed github repo](https://github.com/Seeed-Solution/SenseCAP-Decoder/blob/main/T1000/TTN/SenseCAP_T1000_TTN_Decoder.js)
(this is the TTN codec, which is compatible with ChirpStack V4, there is a ChirpStack V3 codec in the same repo in case
you are using an old version).

![image](https://github.com/user-attachments/assets/bc572786-9853-4b29-baf1-d6f4349b4aa5)

### Add Application and first Device

The next step is to create an application and add actual devices to it.
Go to the applications section and add a new application.

![image](https://github.com/user-attachments/assets/5dc700c6-7faa-4d65-9d94-aa2543f06254)

Then add a device to the application and enter the devEUI as captured in the Sense Craft app earlier.

![image](https://github.com/user-attachments/assets/93febc5b-bc8f-430b-83e0-55d89690355c)

On the variables tab add a variable called `app_eui` with the AppEUI from the Sense Craft app as value:

![image](https://github.com/user-attachments/assets/90e529d7-811b-49cd-902d-85e36b2f6313)

Hitting submit will bring up a page asking for the AppKey, again as captured earlier using the Sense Craft app:

![image](https://github.com/user-attachments/assets/db33a84c-c31f-402f-b9b1-53fa47fc497d)

### Watch your T1000 connect

On the LoRaWAN frames tab you will see a spinner and then packets show up as they are received/sent.
Press the button your T1000 to cause it to take a measurement and send a join request to connect with the LNS.
Once this happens, you should see something like this:

![image](https://github.com/user-attachments/assets/060873cb-c1d8-40bd-9ad3-7333966d3558)

Once the join process has been performed the T1000 sends data. The LNS responds back with some information about the network
frequencies and such, but subsequent to that there should only be uplinks with data.

The actual data as decoded by the codec can be seen on the events tab, except that initially the ChirpStack V3 codec was used
for this device so an error is shown (see the red circle).
Using the TTN codec works and one can see the actual data values by clicking on the `+up` button (green circle).

![image](https://github.com/user-attachments/assets/a12d8a4c-5e8d-47b4-b1f5-1cfaea36f227)

## Helium Console Configuration

The Helium console is no longer open for new accounts. The description for how to connect a T1000 to the Helium Console
remains here for users that already have an account. For new users, please refer to the ChirpStack LNA steps above or determine
the necessary steps for your particular LNA based on the two existing examples here.

### Add New Device

Expand Down Expand Up @@ -930,4 +1004,4 @@ So if the upload interval you set is less than 4 minutes, real-time data will be
## Resource
[SenseCAP T1000 Tracker Decoder for Helium](https://github.com/Seeed-Solution/SenseCAP-Decoder/blob/main/T1000/Helium/SenseCAP_T1000_Helium_Decoder.js)
[SenseCAP T1000 Tracker Decoder for Helium](https://github.com/Seeed-Solution/SenseCAP-Decoder/blob/main/T1000/Helium/SenseCAP_T1000_Helium_Decoder.js)

0 comments on commit 8a59874

Please sign in to comment.