Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom laser +galvo driver introducing to custom type creation and management #472

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions examples/projects/product/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<a href="https://luos.io"><img src="https://uploads-ssl.webflow.com/601a78a2b5d030260a40b7ad/603e0cc45afbb50963aa85f2_Gif%20noir%20rect.gif" alt="Luos logo" title="Luos" align="right" height="100" /></a>

![](https://github.com/Luos-io/luos_engine/actions/workflows/build.yml/badge.svg)
[![](https://img.shields.io/github/license/Luos-io/luos_engine)](https://github.com/Luos-io/luos_engine/blob/master/LICENSE)

[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://www.luos.io)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/luos/library/luos_engine.svg)](https://registry.platformio.org/libraries/luos_engine/luos_engine)

[![](https://img.shields.io/discord/902486791658041364?label=Discord&logo=discord&style=social)](https://discord.gg/luos)
[![](https://img.shields.io/badge/LinkedIn-Share-0077B5?style=social&logo=linkedin)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fluos-io)

# The complete product example :bulb:

This example demonstrates how to deal with a real life project using Luos_engine. This code folder deals with custom types, custom messages commands, and demonstrate how to adapt your gate and pyluos to properly handle it.

This project is a laser Galvo controller example that can be used in an engraving machine, a small surface laser cutter or a laser show device.
This has been tested with the great [interface board made by the opengalvo OPAL project](https://github.com/leswright1977/OPAL_PCB) on STM32-L476RG and a simple cat laser pointer toy.

![The demonstration of a running galvo with a nucleo-L476RG.](galvo_demo.gif)

This product is composed of multiple nodes:

- A gate node called `custom_gate` running on your computer
- A laser Galvo node called `laser_galvo` running on a microcontroller (tested on STM32-L476RG, but it should work on most microcontrollers within the STM32 family).

In this folder, you can also find a Python notebook `laser_galvo_control.ipynb` to control the laser Galvo.

To learn more about how to deal with complete product project with Luos please read our [code organization documentation](https://www.luos.io/docs/luos-technology/basics/organization).

## How to use :computer:

1. Download and install [Platformio](https://platformio.org/platformio-ide)
2. Open the `custom_gate` folder into Platformio
3. Build (Platformio will do the rest)
4. Open the `laser_galvo` folder into Platformio
5. Build and flash the board (Platformio will do the rest) (of course your board with the galvo should be connected to your computer)
6. Run the `custom_gate` program in `custom_gate/.pio/build/native_serial/program` (or `custom_gate/.pio/build/native_serial/program.exe` if you use windows)
7. Install python requirements with `pip install -r requirements.txt`
8. Then you can play with the Ipython notebook `laser_galvo_control.ipynb` to control the laser Galvo

## Don't hesitate to read [our documentation](https://www.luos.io/docs/luos-technology), or to post your questions/issues on the [Luos' community](https://discord.gg/luos). :books:

[![](https://img.shields.io/badge/Luos-Documentation-34A3B4)](https://www.luos.io)
[![](https://img.shields.io/badge/LinkedIn-Follow%20us-0077B5?style=flat&logo=linkedin)](https://www.linkedin.com/company/luos)
2 changes: 1 addition & 1 deletion examples/projects/product/custom_gate/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@
#define SERIAL_RX_BUFFER_SIZE 65000
#define INIT_TIME 150
#define GATE_REFRESH_TIME_S 0.05f
#define SERIAL_PORT "/dev/cu.usbmodem1202" // "/dev/cu.usbserial-D308N897"
#define SERIAL_PORT "/dev/cu.usbmodem1102" // "/dev/cu.usbserial-D308N897"

#endif /* _NODE_CONFIG_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ void Convert_CustomJsonToMsg(service_t *service, uint16_t target_id, char *prope
Luos_SendMsg(service, &msg);
return;
}
if (property && !strcmp(property, "sampling_freq"))
{
float freq = (float)json_getReal(jobj);
time_luos_t period = TimeOD_TimeFrom_s(1.0f / freq);
TimeOD_TimeToMsg(&period, &msg);
Luos_SendMsg(service, &msg);
return;
}
}

// This function is called by the gate to convert a message into a piece of Json.
Expand Down
Binary file added examples/projects/product/galvo_demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions examples/projects/product/laser/include/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
******************************************************************************
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GPIO_H__
#define __GPIO_H__

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_GPIO_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif
#endif /*__ GPIO_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
76 changes: 76 additions & 0 deletions examples/projects/product/laser/include/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define BTN_Pin GPIO_PIN_11
#define BTN_GPIO_Port GPIOA
#define LED_Pin GPIO_PIN_3
#define LED_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Loading
Loading