Running encoder on Arduino Mega using Simulink - arduino

I am using Simulink togheter with an Arduino Mega 2560 to control a motor with encoder. The encoder has 200 steps per revolution. My aim is to use external mode in order to get out data into the Simulink scope.
Earlier, when not using the Simulink blocks, this worked fine using attachInterupt. Now it does not work since Simulink does not have that option. I have tried two methods:
use the digital input blocks and trigger > too slow
use the serial block togheter with an extra arduino (uno) that Only handles the encoder signal (this extra arduino is not programmed in Simulink) and sends the pulses to the main arduino (the baudrate does not seem to the limiting factor, instead it is the fact that the block only handles uint8) > also too slow
I cannot see the generated code in my Simulink license, and I would prefer a solution where blocks are used. Is there a work-around??
Any tip is appreciated!

you may use S-function to develop encoder algorithm using the attachinterrupt of arduino. this link may help http://www.mathworks.com/matlabcentral/fileexchange/39354-device-drivers

Update: You can use the External Interrupt block to implement this in the latest version of the support package.

Related

ESP32 CAM - EEPROM / sdcard / non erasable memory - beginner problem

Overwiew
I am working on my first project with ESP32, I have ESP32 CAM model and I am creating an automatic roller blinds. I got most of the project working - I have web server that controls continous servo and all mechanics. I want to be able to adjust the time for going up-down without reprograming the microcontroller. The goal is to have an automatic roller blinds with alarm clock function.
Problem
I need a way to reliable save/read data to store variables state, even without power. How to achive it with ESP32 CAM?
Additional info
On Arduino board that would be EEPROM, and I found some tutorials that claim that EEPROM can be used on ESP32. However, when I tried using EEPROM, it looks like the values are overwritten while bootloading. So I guess ESP32 CAM needs different approach. Correct me if I am wrong, please.
Ok, so user bvguy on Reddit solved my problem.
"EEPROM is deprecated. They want you to use preferences now. Here is an example ."
I tested the example and it works on my ESP32 CAM, therfore solving the problem.

Why do we need to select a board to work with arduino IDE

I always wondered how this works . In arduino IDE we have option to select different boards because the code upload i guess is different ? Also there is possibility to even add board manager url to add other boards.
Why uploading the code is so different from board to board , and what exactly differs there ? The code is sent to via serial connection and i understand that a board might have different chip for handling USB to serial but ..
Can someone explain as clear as possible , how the code is uploaded to a board and why there is no generic way , why so many configurations.
Thanks and sorry if is a dumb question.
One of the important things that selecting a board does is, as you say, inform the IDE of how to load code onto the board. Perhaps more importantly, the board definitions give you the logical mapping of the board's hardware to the code constructs you are using to program against. For example, have you ever wondered what happens when you use a constant like PIN_13, or how that constant maps to a physical pin on your board, which has a trace to some contact on the microcontroller chip itself?
There is a lot of other code you don't see, much of it in the board definitions (and some in the Arduino core) which lets you work with relatively direct concepts (like pin numbers and modes) in the code that you write or edit.

Need to bootload multiple times when using Nick Gammons program

I have been facing this issue with Nick Gammon's Arduino boot loader that every time I bootload and write a program via Rx-Tx to an Atmega 2560 but if I want to re write another program the IDE shows an error and the whole process has to be repeated, is this normal behaviour?
Its sort of an issue as I am programming an LCD and need to make lots of small changes.
TIA.

Joystick USB definition for use with Arduino

I'm trying to write the control code for a custom joystick, and I cannot find any reference to what needs to be implemented to be recognized by a computer as a joystick.
I can see what things I need to have by referencing various game library APIs for using a joystick.
For example, pygame has the following methods,
init
quit
get_init
get_name
get_id
get_numaxes
get_numbuttons
etc.
My next stop is to read through the kernel for Linux's HID and joystick controlers... But this seems like a really round about way of finding this information.
I haven't worked with it, but it looks like there is some interesting information in Arduino Uno Joystick HID firmware and Arduino Uno Big Joystick HID firmware. There is also UnoJoy - I'd try that first (assuming you have an Arduino Uno or Leonardo).

Arduino ethernet board compatible with LCD-Display?

I am doing a little project with an arduino ethernet board. I am new to arduino and wanted to know, whether following lcd display is compatible to my arduino or not. If it is compatible, do I need more hardware, for example cables and so on...
My Arduino Ethernet board, bought on fritzing.org:
http://shop.fritzing.org/products/fritzing-starter-kit-with-arduino-ethernet
LCD-Display which I found on dx.com:
http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059
Thanks in advance for any help!
In the ethernet board, pins 10-13 are reserved. The lcd-shield is using pins 4-10 (although #10 is the backlit control, so it may be possible to go without it, just having a constant backlit) - I have the lcd - keypad shield, but at home, so I cannot check that now. - look into the lcd-library to see if you can somehow define it.
That is, it is not possible to use the backlight and the ethernet at the same time. For your other question, you just stack the LCD -keypad shield on top of your arduino board, no other connections or cables are needed.
Although it may look a bit more scary, a display without a shield, eg http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356 is not much harder to set up and it gives you more flexibility. (although, for the display I linked to, you must be able to solder in a set of pins to connect it) Another alternative is http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356 - the latter gives you more flexibility, but poorer readability and it is a bit more work to set up the library.

Resources