Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Communicatie tussen twee Arduino's onderling

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
drejansen

Bascom Member



Joined: 10 Jun 2006
Posts: 26
Location: Hoeksche Waard

netherlands.gif
PostPosted: Fri Nov 04, 2016 6:57 pm    Post subject: Communicatie tussen twee Arduino's onderling Reply with quote

English below

geacht forum,

enkele jaren geleden stond er in Elektor een verhaal over micro controllers voor beginners.
programmeertaal is Bascom.

dit vervolgverhaal heb ik gevolgd en in ben nu op bladzijde 75 van september 2014
hierin wordt een frequentiemeting met Arduino -1- gedaan, dat op een LCD schermpje van Arduino -2- moet worden weergegeven.

wanneer ik volgens de omschrijving op com-1 aansluit, dan gebeurd er niets.
uiteraard zijn de snelheid en andere instellingen van beide arduino's is gelijk.
wanneer ik poort #2 gebruik, dan krijg ik de onzinnige cijferreeksen. Hz krijg ik wel te zien
ik krijg dus wel contact en een heleboel onzin op het scherm.
ergens gaat er iets mis, maar WAT??

wie o wie heeft ook dit verhaal gevolgd en kan mij uit de brand helpen?
mijn dank is groot en joUw roem is eeuwig!

groeten, Dré Jansen

===========

deemed forum

A few years ago there was in Elektor a story about microcontrollers for beginners.
programming language is Bascom.

this serial I followed and am now on page 75 of September 2014
herein a frequency measurement is done with Arduino -1, to be displayed on an LCD screen Arduino -2-.

When I connect to com-1 according to the definition, then nothing happens.
Of course the speed and other settings of both Arduino are equal.
When I use port # 2, I get the nonsense of figures. Hz I do get to see
I get so well connected and a lot of crap on the screen.
something goes wrong, but WHAT ??

o those who has followed this story and can help me out the fire?
My gratitude is great, and your glory is eternal!

greetings, Dré Jansen

_________________
Pluk het moment!
een hele dag lukt toch niet.
 
Groeten, Dré Jansen
 
 
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Sun Nov 06, 2016 11:11 am    Post subject: Reply with quote

hi,
please post your program,
I will test it . try to put some English comment , I learnt a little bit the German language but it was so far.... Crying or Very sad
jp Wink
Back to top
View user's profile Visit poster's website
drejansen

Bascom Member



Joined: 10 Jun 2006
Posts: 26
Location: Hoeksche Waard

netherlands.gif
PostPosted: Mon Nov 07, 2016 12:28 pm    Post subject: Communicatie tussen Arduino's onderling Reply with quote

Duval JP wrote:
hi,
please post your program,
I will test it . try to put some English comment , I learnt a little bit the German language but it was so far.... Crying or Very sad
jp Wink



Hi JP Duval,

Thanks that you want to look at my problem.
I following a course from 2014 in the Elektor magazine.
The program: “UNO_Timer6.bas” is a frequency counter.
Input at D.5 range 0…4 MHz, this works perfect!
It gives the result on the PC screen.
In it is also a test signal of 31373 Hz

'-------------------------------------------------------------------------------
'UNO_Timer6.BAS Frequency 0...4 MHz
'-------------------------------------------------------------------------------
$regfile = "m328pdef.dat" 'ATmega328p
$crystal = 16000000 '16 MHz
$baud = 9600

Dim Lowword As Word
Dim Highword As Word
Dim Ticks As Word
Dim Freq As Long

Config Timer0 = Timer , Prescale = 64
On Ovf0 Tim0_isr
Enable Timer0

Config Timer1 = Counter , Edge = Falling , Prescale = 1
On Ovf1 Tim1_isr
Enable Timer1

Config Timer2 = Pwm , Prescale = 1 , Compare A Pwm = Clear Up
Pwm2a = 128 'B3: 31373 Hz
Enable Interrupts

Do
Print Freq;
Print " Hz ";
Print Chr(13);
Waitms 1000
Loop

Tim0_isr:
'1000 µs
Timer0 = 6
Ticks = Ticks + 1
If Ticks = 1 Then
Timer1 = 0
Highword = 0
End If
If Ticks = 1001 Then
Lowword = Timer1
Freq = Highword * 65536
Freq = Freq + Lowword
Ticks = 0
End If
Return

Tim1_isr:
Highword = Highword + 1
Return
End

This output signal is also available at pin D.1

Elektor has also a program to read this at a second Arduino.
I use an Arduino Nano for this
The receive program is called: “UNO_Display.bas”
This gives the problem, it does not work properly
I get rubbish on the screen.

'-------------------------------------------------------------------------------
'UNO_Display.BAS COM input B0
'-------------------------------------------------------------------------------
$regfile = "m328pdef.dat" 'ATmega328p
$crystal = 16000000 '16 MHz
$baud = 9600

Dim Text1 As String * 16
Dim Text2 As String * 16

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Cls
Cursor Off
Open "comb.0:9600,8,n,1" For Input As #2 'Software COM input at B0


Do
'Input Text1
Input #2 , Text1
Locate 1 , 1
Lcd Text2
Text2 = Text1 + " "
Locate 2 , 1
Lcd Text2
Loop

End

What goes wrong? What do I wrong?
There are two possible inputs the standard data input at receive D.1 and an alternative D.8 = B.0 this is input#2
In this example is ‘input text1 is switched off with an apostrophe '

The question: how can I receive text and numbers from one to an other Arduino?
Both programs are the original programs from the course

Best regards, Dré Jansen

_________________
Pluk het moment!
een hele dag lukt toch niet.
 
Groeten, Dré Jansen
 
 
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Mon Nov 07, 2016 5:39 pm    Post subject: Reply with quote

hi Dre,
1)

from the help :
* when you use a timer interrupt that occurs each 10 uS for example, be sure that the interrupt code can execute in 10 uS. Otherwise you would loose time.
* it is best to set just a simple flag in the interrupt routine and to determine it's status in the main program

2)
first test your LCD : with this simple program

$regfile = "M328pdef.dat"
$crystal = 16000000
$hwstack = 128
$swstack = 64
$framesize = 128

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
locate 1,1 :lcd "1234567890123456"
locate 2,1 :lcd "1234567890123456"
end

3)use this very common header :
'-------------------------------------------------------------------------------
' ARDUINO-UNO V3.BAS
'
' (c) 1995-2011, MCS Electronics
' This is a sample file for the Mega328P based ARDUINO board
' Select Programmer 'ARDUINO' , 115200 baud and the proper COM port timeout 200
'-------------------------------------------------------------------------------

$regfile = "M328pdef.dat"
$crystal = 16000000
$hwstack = 128
$swstack = 64
$framesize = 128
' les config----------------------------------------------------------------------
Config Clockdiv = 1 'by défault le M328 use a clock diviser 8

------------------------------------------------------------------------------------
I'm sorry, actually I cant test your program , I did a course saturday and a student kill my uno Rolling Eyes
JP
Back to top
View user's profile Visit poster's website
drejansen

Bascom Member



Joined: 10 Jun 2006
Posts: 26
Location: Hoeksche Waard

netherlands.gif
PostPosted: Mon Nov 07, 2016 6:54 pm    Post subject: Communicatie tussen Arduino's onderling Reply with quote

Hi JP,
Thanks!

HURRAY!!! It works!
the command: Config Clockdiv = 1 was the solution!
thanks again, I can sleep well tonight
I hope your Uno is reparable, others, Banggood sells them cheap.

greetings, Dré

_________________
Pluk het moment!
een hele dag lukt toch niet.
 
Groeten, Dré Jansen
 
 
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Tue Nov 08, 2016 10:29 am    Post subject: Reply with quote

Hello Dré,
Quote:

Hi JP,
Thanks!

HURRAY!!! It works!

Very Happy I'm happy to solve your problem

Yes, I'm customer of banggood too. in a few day I will publish a new application :a request from my wife , follow me ! Wink

JP
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum